couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [couchdb-fauxton] branch master updated: (#951) - Set safeUrlName to always encode a name
Date Thu, 10 Aug 2017 15:27:15 GMT
This is an automated email from the ASF dual-hosted git repository.

garren pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git


The following commit(s) were added to refs/heads/master by this push:
     new 376e495   (#951) - Set safeUrlName to always encode a name
376e495 is described below

commit 376e495c4e66671201d63bfeb99def8a12be21b2
Author: garren smith <garren.smith@gmail.com>
AuthorDate: Thu Aug 10 17:27:12 2017 +0200

     (#951) - Set safeUrlName to always encode a name
---
 app/core/tests/utilsSpec.js | 9 ++++-----
 app/core/utils.js           | 3 ++-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/app/core/tests/utilsSpec.js b/app/core/tests/utilsSpec.js
index ddc6b46..ada4bfb 100644
--- a/app/core/tests/utilsSpec.js
+++ b/app/core/tests/utilsSpec.js
@@ -48,14 +48,13 @@ describe('Utils', function () {
 
   describe('safeURLName', function () {
 
-    it('is idempotent', function () {
-      assert.equal('foo-bar%2Fbaz', utils.safeURLName(utils.safeURLName('foo-bar/baz')));
-      assert.equal('foo-bar%2Bbaz', utils.safeURLName(utils.safeURLName('foo-bar+baz')));
-    });
-
     it('encodes special chars', function () {
       assert.equal('foo-bar%2Fbaz', utils.safeURLName('foo-bar/baz'));
     });
+
+    it('encodes an encoded doc', function () {
+      assert.equal('foo-bar%252Fbaz', utils.safeURLName('foo-bar%2Fbaz'));
+    });
   });
 
   describe('isSystemDatabase', function () {
diff --git a/app/core/utils.js b/app/core/utils.js
index 3c0d33f..b5b736c 100644
--- a/app/core/utils.js
+++ b/app/core/utils.js
@@ -67,7 +67,8 @@ const utils = {
   safeURLName: function (name = "") {
     // These special caracters are allowed by couch: _, $, (, ), +, -, and /
     // From them only $ + and / are to be escaped in a URI component.
-    return (/[$+/]/g.test(name)) ? encodeURIComponent(name) : name;
+    // return (/[$+/]/g.test(name)) ? encodeURIComponent(name) : name;
+    return encodeURIComponent(name);
   },
 
   getDocTypeFromId: function (id) {

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <commits@couchdb.apache.org>'].

Mime
View raw message