couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benk...@apache.org
Subject fauxton commit: updated refs/heads/master to 88148d6
Date Wed, 25 Feb 2015 15:49:56 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master 7f118dfc0 -> 88148d626


Fix for encoding unicode char

Contains a small fix to ensure a unicode char in the db typeahead
component is URL encoded. If the server needed to recognize the
endkey parameter it would cause problems on IE.

Closes COUCHDB-2587


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/88148d62
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/88148d62
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/88148d62

Branch: refs/heads/master
Commit: 88148d626d44d15dbebd7e2317c54b13ae69bf09
Parents: 7f118df
Author: Ben Keen <ben.keen@gmail.com>
Authored: Tue Feb 17 14:05:13 2015 -0800
Committer: Ben Keen <ben.keen@gmail.com>
Committed: Wed Feb 25 07:50:36 2015 -0800

----------------------------------------------------------------------
 app/addons/fauxton/components.js           | 15 ++++++----
 app/addons/fauxton/tests/componentsSpec.js | 40 +++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/88148d62/app/addons/fauxton/components.js
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/components.js b/app/addons/fauxton/components.js
index 462a424..c59a7f2 100644
--- a/app/addons/fauxton/components.js
+++ b/app/addons/fauxton/components.js
@@ -615,19 +615,24 @@ function(app, FauxtonAPI, ace, spin, ZeroClipboard) {
       }
       _.bindAll(this);
     },
-    source: function(query, process) {
+
+    getURL: function (query, dbLimit) {
       query = encodeURIComponent(query);
-      var resultFilter = this.resultFilter;
-      var url = [
+      return [
         app.host,
         "/_all_dbs?startkey=%22",
         query,
         "%22&endkey=%22",
         query,
-        "\u9999",
+        encodeURIComponent("\u9999"),
         "%22&limit=",
-        this.dbLimit
+        dbLimit
       ].join('');
+    },
+
+    source: function(query, process) {
+      var url = this.getURL(query, this.dbLimit);
+      var resultFilter = this.resultFilter;
 
       if (this.ajaxReq) { this.ajaxReq.abort(); }
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/88148d62/app/addons/fauxton/tests/componentsSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/tests/componentsSpec.js b/app/addons/fauxton/tests/componentsSpec.js
new file mode 100644
index 0000000..cf9ae0e
--- /dev/null
+++ b/app/addons/fauxton/tests/componentsSpec.js
@@ -0,0 +1,40 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+define([
+  'testUtils',
+  'api',
+  'addons/fauxton/components'
+], function (testUtils, FauxtonAPI, Components) {
+  var assert = testUtils.assert;
+
+
+  describe('DbSearchTypeahead', function () {
+
+    // simple test to confirm that the query part of the URL and the \u9999 search end char
+    // are URL encoded
+    it('should URI encode parts of URL', function () {
+      var dbLimit = 30;
+      var typeahead = new Components.DbSearchTypeahead({
+        dbLimit: dbLimit
+      });
+      var url = typeahead.getURL('querywith[]chars', dbLimit);
+
+      // confirm the [] chars have been encoded
+      assert.isTrue(/%5B%5D/.test(url));
+
+      // confirm the \u9999 char has been encoded
+      assert.isFalse(/\u9999/.test(url));
+      assert.isTrue(/%E9%A6%99/.test(url));
+    });
+  });
+
+});


Mime
View raw message