Avoid badmatch when replicator dbnames have leading slashes. Closes COUCHDB-317
Patch by Joan Touzet. Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/5d92ae8f Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/5d92ae8f Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/5d92ae8f Branch: refs/heads/master Commit: 5d92ae8fa9bfb1c21fb4d974671cf6ae3f5b409a Parents: 93f58e8 Author: Jan Lehnardt <[email protected]> Authored: Sat Jan 26 18:14:42 2013 +0100 Committer: Jan Lehnardt <[email protected]> Committed: Sat Jan 26 18:27:49 2013 +0100 ---------------------------------------------------------------------- THANKS.in | 1 + share/www/script/test/replication.js | 9 +++++++++ .../src/couch_replicator_api_wrap.erl | 2 ++ 3 files changed, 12 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d92ae8f/THANKS.in ---------------------------------------------------------------------- diff --git a/THANKS.in b/THANKS.in index 4ebf3f0..ec0f8d3 100644 --- a/THANKS.in +++ b/THANKS.in @@ -94,6 +94,7 @@ suggesting improvements or submitting changes. Some of these people are: * Fedor Indutny <[email protected]> * Tim Blair * Tady Walsh <[email protected]> + * Joan Touzet <[email protected]> # 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. http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d92ae8f/share/www/script/test/replication.js ---------------------------------------------------------------------- diff --git a/share/www/script/test/replication.js b/share/www/script/test/replication.js index 2b23af5..fd60dd4 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"); http://git-wip-us.apache.org/repos/asf/couchdb/blob/5d92ae8f/src/couch_replicator/src/couch_replicator_api_wrap.erl ---------------------------------------------------------------------- diff --git a/src/couch_replicator/src/couch_replicator_api_wrap.erl b/src/couch_replicator/src/couch_replicator_api_wrap.erl index dcd6ca8..90cfa8e 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 ->
