Description
Steps:
1. Open DB named: "`~@#$%^&*()_+{}|\\][=-/.,<>?\":;'" is failing.
- It started showing up when I switch to new LiteCore API and ran the unit test (`c4db_openNamed`)
iOS unit test: `testCreateWithSpecialCharacterDBNames`
https://github.com/couchbase/couchbase-lite-ios/blob/e264154e767dd458b349245f6d7871f9e8dfc0b7/Objective-C/Tests/DatabaseTest.m#L176
Back Trace
(lldb) bt
|
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
|
* frame #0: 0x00007fff20252326 libc++abi.dylib`__cxa_throw
|
frame #1: 0x000000010f93571b CouchbaseLite`litecore::error::_throw(this=0x00007ffee1d0b390) at Error.cc:549:9
|
frame #2: 0x000000010f935bbc CouchbaseLite`litecore::error::_throw(domain=POSIX, code=2) at Error.cc:555:29
|
frame #3: 0x000000010f936005 CouchbaseLite`litecore::error::_throwErrno() at Error.cc:564:9
|
frame #4: 0x000000010fb92b97 CouchbaseLite`litecore::FilePath::mkdir(this=0x00007ffee1d0b600, mode=448) const at FilePath.cc:550:17
|
frame #5: 0x000000010fb68e1b CouchbaseLite`c4Internal::Database::findOrCreateBundle(path="/Users/jayaharivavachan/Library/Developer/CoreSimulator/Devices/8919F7F8-3ADF-4856-B48B-2B692F228C2A/data/Containers/Data/Application/DBF32F6F-CEDE-41AE-9BBB-6892EB5323DB/tmp/CouchbaseLite_EE/`~@#$%^&*()_+{}|\\][=-/.,<>?\":;'.cblite2", canCreate=true, storageEngine=0x00007ffee1d0b6f8) at Database.cc:65:48
|
frame #6: 0x000000010fb69505 CouchbaseLite`c4Internal::Database::Database(this=0x00007feb1ff07c10, bundlePath="/Users/jayaharivavachan/Library/Developer/CoreSimulator/Devices/8919F7F8-3ADF-4856-B48B-2B692F228C2A/data/Containers/Data/Application/DBF32F6F-CEDE-41AE-9BBB-6892EB5323DB/tmp/CouchbaseLite_EE/`~@#$%^&*()_+{}|\\][=-/.,<>?\":;'.cblite2", inConfig=C4DatabaseConfig @ 0x00007ffee1d0b6f0) at Database.cc:108:15
|
frame #7: 0x000000010f9bf0a3 CouchbaseLite`c4Database::c4Database(this=0x00007feb1ff07c10, path=0x00007ffee1d0ba58, config=C4DatabaseConfig @ 0x00007ffee1d0b7d0) at c4Database.hh:27:6
|
frame #8: 0x000000010f9bea2a CouchbaseLite`c4Database::c4Database(this=0x00007feb1ff07c10, path=0x00007ffee1d0ba58, config=C4DatabaseConfig @ 0x00007ffee1d0b830) at c4Database.hh:27:29
|
frame #9: 0x000000010f9bf24b CouchbaseLite`c4db_openNamed::$_1::operator(this=0x00007ffee1d0ba58)() const at c4Database.cc:121:27
|
frame #10: 0x000000010f9bf185 CouchbaseLite`c4Database* fleece::function_ref<c4Database* ()>::callback_fn<c4db_openNamed::$_1>(callable=140732686973528) at function_ref.hh:59:12
|
frame #11: 0x000000010f9be759 CouchbaseLite`fleece::function_ref<c4Database* ()>::operator(this=0x00007ffee1d0b978)() const at function_ref.hh:72:12
|
frame #12: 0x000000010f9bb00d CouchbaseLite`c4Database* c4Internal::tryCatch<c4Database*>(outError=0x00007ffee1d0bb68, fn=function_ref<c4Database *()> @ 0x00007ffee1d0b978)>) at c4ExceptionUtils.hh:60:20
|
frame #13: 0x000000010f9bb245 CouchbaseLite`::c4db_openNamed(name=(buf = 0x000000010eae2d4f, size = 31), config=0x00007ffee1d0bc10, outError=0x00007ffee1d0bb68) at c4Database.cc:120:12
|
frame #14: 0x000000010f80cf59 CouchbaseLite`-[CBLDatabase open:](self=0x0000600003ed8200, _cmd="open:", outError=0x00007ffee1d0c4b8) at CBLDatabase.mm:772:13
|
frame #15: 0x000000010f805cf0 CouchbaseLite`-[CBLDatabase initWithName:config:error:](self=0x0000600003ed8200, _cmd="initWithName:config:error:", name="`~@#$%^&*()_+{}|\\][=-/.,<>?\":;'", config=0x00006000010a0720, outError=0x00007ffee1d0c4b8) at CBLDatabase.mm:114:14
|
frame #16: 0x000000010ea0e584 CBL_EE_Objc_Tests_iOS`-[CBLTestCase openDBNamed:error:](self=0x0000600002cf8000, _cmd="openDBNamed:error:", name=@"`~@#$%^&*()_+{}|\\][=-/.,<>?\":;'", error=0x00007ffee1d0c4b8) at CBLTestCase.m:112:12
|
frame #17: 0x000000010e538648 CBL_EE_Objc_Tests_iOS`-[DatabaseTest testCreateWithSpecialCharacterDBNames](self=0x0000600002cf8000, _cmd="testCreateWithSpecialCharacterDBNames") at DatabaseTest.m:179:23
|
Unit test
N_WAY_TEST_CASE_METHOD(C4DatabaseTest, "DatabaseName SpecialChars", "[Database][C][!throws]") {
|
auto config = *c4db_getConfig2(db);
|
|
static constexpr slice kTestBundleName = "`~@#$%^&*()_+{}|\\][=-/.,<>?\":;'";
|
C4Error error;
|
if (!c4db_deleteNamed(kTestBundleName, config.parentDirectory, &error))
|
REQUIRE(error.code == 0);
|
auto bundle = c4db_openNamed(kTestBundleName, &config, &error);
|
REQUIRE(bundle);
|
CHECK(c4db_getName(bundle) == kTestBundleName);
|
C4SliceResult path = c4db_getPath(bundle);
|
CHECK(path == TEMPDIR("`~@#$%^&*()_+{}|\\][=-/.,<>?\":;'.cblite2" kPathSeparator)); // note trailing '/'
|
c4slice_free(path);
|
REQUIRE(c4db_close(bundle, &error));
|
c4db_release(bundle);
|
|
// Reopen without 'create' flag:
|
config.flags &= ~kC4DB_Create;
|
bundle = c4db_openNamed(kTestBundleName, &config, &error);
|
REQUIRE(bundle);
|
REQUIRE(c4db_close(bundle, &error));
|
c4db_release(bundle);
|
|
// Reopen with wrong storage type:
|
{
|
ExpectingExceptions x;
|
// Open nonexistent bundle:
|
REQUIRE(!c4db_openNamed("`~@#$%^&*()_+{}|\\][=-/.,<>?\":;'"_sl, &config, &error));
|
}
|
}
|