Skip to content

Commit

Permalink
Adding fix for non-ascii characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zach Manring committed May 26, 2014
1 parent e995264 commit 663cfc4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
27 changes: 24 additions & 3 deletions assets/javascripts/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
transformRequest: function (obj) {
var str = [];
for (var p in obj) {
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p].trim()).replace(/\%20/g,'+'));
}
return str.join('&');
},
Expand Down Expand Up @@ -422,6 +422,27 @@
localStorage.clear();
};

Delicious.replaceNonAscii = function (str) {

if (str) {

str = str.replace(/\xE4/g, 'ae'); /* ä */
str = str.replace(/\xF6/g, 'oe'); /* ö */
str = str.replace(/\xFC/g, 'ue'); /* ü */
str = str.replace(/\xC4/g, 'Ae'); /* Ä */
str = str.replace(/\xD6/g, 'Oe'); /* Ö */
str = str.replace(/\xDC/g, 'Ue'); /* Ü */
str = str.replace(/\xDF/g, 'ss'); /* ß */

// Everything else
str = str.replace(/[^\x00-\x7F]/g, '');

}

return str;

};

Delicious.setting = (function () {
var prefix = 'chrome-ext-delicious-setting-',
defaults = {
Expand Down Expand Up @@ -534,11 +555,11 @@
});

controllers.controller('NewLinkCtrl', function ($scope, $location, tab, delicious, analytics) {
$scope.description = tab.title.replace(/[^\x00-\x7F]/g, "");
$scope.description = delicious.replaceNonAscii(tab.title);
$scope.header = 'Add link to Delicious';
$scope.myTags = [];
$scope.myTagsLoaded = false;
$scope.note = tab.selectionText;
$scope.note = delicious.replaceNonAscii(tab.selectionText);
$scope.submitLabel = 'Add';
$scope.suggestedTags = [];
$scope.tags = [];
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"https://api.del.icio.us/",
"tabs"
],
"version": "2.9.8",
"version": "2.9.9",
"web_accessible_resources": ["/popup.html"]

}
7 changes: 7 additions & 0 deletions updated.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ <h2>Changelog</h2>
</p>

<article class="latest">
<h4>Version 2.9.9</h4>
<ul>
<li>Added fix for non-ascii characters, causing issues when saving links</li>
</ul>
</article>

<article>
<h4>Version 2.9.7</h4>
<ul>
<li>Removed auto update/changelog page to show on new installs</li>
Expand Down

0 comments on commit 663cfc4

Please sign in to comment.