Permalink
Browse files

Avoid badmatch when replicator dbnames have leading slashes.

Closes COUCHDB-317

Patch by Joan Touzet.
  • Loading branch information...
1 parent 959664c commit 324d49f723e6cd7c4bf4e6244700fcce948e1597 @janl janl committed with benoitc Jan 26, 2013
@@ -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");
@@ -94,6 +94,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 ->

0 comments on commit 324d49f

Please sign in to comment.