couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject fauxton commit: updated refs/heads/master to dd46a41
Date Thu, 23 Feb 2017 07:06:27 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master f8269b6cb -> dd46a41df


Replication: hotfix url parsing for invalid urls

See COUCHDB-3257: sometimes the replicator returns invalid urls
which are not encoded. This makes standard conforming url parsers
choke.

This catches the exception, with the tradeoff of displaying the
password in the cases where the url is invalid.


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

Branch: refs/heads/master
Commit: dd46a41df50e03449395424083c29ff66cd76fa6
Parents: f8269b6
Author: Robert Kowalski <robertkowalski@apache.org>
Authored: Fri Dec 16 14:27:35 2016 +0100
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Thu Feb 23 08:42:01 2017 +0200

----------------------------------------------------------------------
 app/addons/replication/__tests__/api.tests.js | 23 +++++++++++++++++++++-
 app/addons/replication/api.js                 | 10 +++++++---
 2 files changed, 29 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/dd46a41d/app/addons/replication/__tests__/api.tests.js
----------------------------------------------------------------------
diff --git a/app/addons/replication/__tests__/api.tests.js b/app/addons/replication/__tests__/api.tests.js
index f2ad098..3ebb792 100644
--- a/app/addons/replication/__tests__/api.tests.js
+++ b/app/addons/replication/__tests__/api.tests.js
@@ -20,7 +20,8 @@ import {
   encodeFullUrl,
   decodeFullUrl,
   getCredentialsFromUrl,
-  removeCredentialsFromUrl
+  removeCredentialsFromUrl,
+  removeSensitiveUrlInfo
 } from '../api';
 import Constants from '../constants';
 
@@ -28,6 +29,26 @@ const assert = utils.assert;
 
 describe('Replication API', () => {
 
+  describe("removeSensiteiveUrlInfo", () => {
+    it('removes password username', () => {
+        const url = 'http://tester:testerpass@127.0.0.1/fancy/db/name';
+
+        const res = removeSensitiveUrlInfo(url);
+
+        expect(res).toBe('http://127.0.0.1/fancy/db/name');
+      });
+
+      // see https://issues.apache.org/jira/browse/COUCHDB-3257
+      // CouchDB accepts and returns invalid urls
+      it('does not throw on invalid urls', () => {
+        const url = 'http://tester:tes#terpass@127.0.0.1/fancy/db/name';
+
+        const res = removeSensitiveUrlInfo(url);
+
+        expect(res).toBe('http://tester:tes#terpass@127.0.0.1/fancy/db/name');
+      });
+  });
+
   describe('getSource', () => {
 
     it('encodes remote db', () => {

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/dd46a41d/app/addons/replication/api.js
----------------------------------------------------------------------
diff --git a/app/addons/replication/api.js b/app/addons/replication/api.js
index f14e4eb..0bda517 100644
--- a/app/addons/replication/api.js
+++ b/app/addons/replication/api.js
@@ -197,9 +197,13 @@ export const createReplicationDoc = ({
   });
 };
 
-const removeSensitiveUrlInfo = (url) => {
-  const urlObj = new URL(url);
-  return `${urlObj.origin}/${decodeURIComponent(urlObj.pathname.slice(1))}`;
+export const removeSensitiveUrlInfo = (url) => {
+  try {
+    const urlObj = new URL(url);
+    return `${urlObj.origin}/${decodeURIComponent(urlObj.pathname.slice(1))}`;
+  } catch (e) {
+    return url;
+  }
 };
 
 export const getDocUrl = (doc) => {


Mime
View raw message