From 663cfc4a2878bed8e0f737288beb80c70c17e5e5 Mon Sep 17 00:00:00 2001
From: Zach Manring
Date: Sun, 25 May 2014 20:27:56 -0400
Subject: [PATCH] Adding fix for non-ascii characters.
---
assets/javascripts/popup.js | 27 ++++++++++++++++++++++++---
manifest.json | 2 +-
updated.html | 7 +++++++
3 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/assets/javascripts/popup.js b/assets/javascripts/popup.js
index 8f98290..e1622ca 100644
--- a/assets/javascripts/popup.js
+++ b/assets/javascripts/popup.js
@@ -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('&');
},
@@ -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 = {
@@ -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 = [];
diff --git a/manifest.json b/manifest.json
index 57976f3..eb86760 100644
--- a/manifest.json
+++ b/manifest.json
@@ -45,7 +45,7 @@
"https://api.del.icio.us/",
"tabs"
],
- "version": "2.9.8",
+ "version": "2.9.9",
"web_accessible_resources": ["/popup.html"]
}
diff --git a/updated.html b/updated.html
index 0cd4265..4eca400 100644
--- a/updated.html
+++ b/updated.html
@@ -77,6 +77,13 @@ Changelog
+ Version 2.9.9
+
+ - Added fix for non-ascii characters, causing issues when saving links
+
+
+
+
Version 2.9.7
- Removed auto update/changelog page to show on new installs