summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2013-01-26 18:14:42 +0100
committerJan Lehnardt <jan@apache.org>2013-01-26 18:27:49 +0100
commit5d92ae8fa9bfb1c21fb4d974671cf6ae3f5b409a (patch)
tree9e4025cf7b23022fb3c24f4013ac6336050e5712
parent93f58e8adcb04555df7da400ed21800cb97ba19c (diff)
downloadcouchdb-5d92ae8fa9bfb1c21fb4d974671cf6ae3f5b409a.tar.gz
Avoid badmatch when replicator dbnames have leading slashes.
Closes COUCHDB-317 Patch by Joan Touzet.
-rw-r--r--THANKS.in1
-rw-r--r--share/www/script/test/replication.js9
-rw-r--r--src/couch_replicator/src/couch_replicator_api_wrap.erl2
3 files changed, 12 insertions, 0 deletions
diff --git a/THANKS.in b/THANKS.in
index 4ebf3f015..ec0f8d3f6 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -94,6 +94,7 @@ suggesting improvements or submitting changes. Some of these people are:
* Fedor Indutny <fedor@indutny.com>
* Tim Blair
* Tady Walsh <hello@tady.me>
+ * Joan Touzet <joant@ieee.org>
# Authors from commit 6c976bd and onwards are auto-inserted. If you are merging
# a commit from a non-committer, you should not add an entry to this file. When
# `bootstrap` is run, the actual THANKS file will be generated.
diff --git a/share/www/script/test/replication.js b/share/www/script/test/replication.js
index 2b23af5f2..fd60dd41b 100644
--- a/share/www/script/test/replication.js
+++ b/share/www/script/test/replication.js
@@ -497,6 +497,15 @@ couchTests.replication = function(debug) {
} catch (x) {
TEquals("db_not_found", x.error);
}
+
+ // validate COUCHDB-317
+ try {
+ CouchDB.replicate("/foobar", "test_suite_db");
+ T(false, "should have failed with db_not_found error");
+ } catch (x) {
+ TEquals("db_not_found", x.error);
+ }
+
try {
CouchDB.replicate(CouchDB.protocol + host + "/foobar", "test_suite_db");
T(false, "should have failed with db_not_found error");
diff --git a/src/couch_replicator/src/couch_replicator_api_wrap.erl b/src/couch_replicator/src/couch_replicator_api_wrap.erl
index dcd6ca8ca..90cfa8e5a 100644
--- a/src/couch_replicator/src/couch_replicator_api_wrap.erl
+++ b/src/couch_replicator/src/couch_replicator_api_wrap.erl
@@ -89,6 +89,8 @@ db_open(DbName, Options, Create) ->
couch_db:create(DbName, Options)
end,
case couch_db:open(DbName, Options) of
+ {error, illegal_database_name, _} ->
+ throw({db_not_found, DbName});
{not_found, _Reason} ->
throw({db_not_found, DbName});
{ok, _Db} = Success ->