diff options
author | Gil <mcg@google.com> | 2018-05-22 21:39:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-22 21:39:45 -0700 |
commit | 23f8320148672310ff71aa3ef2b6c3ac86d47ede (patch) | |
tree | f5953f6e5e46e64876272cadccfdf771b0ebf3ae /Firestore | |
parent | fb0ba40c00b9d777ccb0bd70e2ebaee1386af4e6 (diff) |
Directly validate collection and document paths (#1316)
... instead of relying on HARD_ASSERTS in resource_path.cc to catch
them.
This fixes an integration test broken in #1304.
Diffstat (limited to 'Firestore')
-rw-r--r-- | Firestore/Source/API/FIRFirestore.mm | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Firestore/Source/API/FIRFirestore.mm b/Firestore/Source/API/FIRFirestore.mm index e5f0c12..5486b75 100644 --- a/Firestore/Source/API/FIRFirestore.mm +++ b/Firestore/Source/API/FIRFirestore.mm @@ -292,6 +292,11 @@ extern "C" NSString *const FIRFirestoreErrorDomain = @"FIRFirestoreErrorDomain"; if (!collectionPath) { FSTThrowInvalidArgument(@"Collection path cannot be nil."); } + if ([collectionPath containsString:@"//"]) { + FSTThrowInvalidArgument(@"Invalid path (%@). Paths must not contain // in them.", + collectionPath); + } + [self ensureClientConfigured]; const ResourcePath path = ResourcePath::FromString(util::MakeStringView(collectionPath)); return [FIRCollectionReference referenceWithPath:path firestore:self]; @@ -301,6 +306,10 @@ extern "C" NSString *const FIRFirestoreErrorDomain = @"FIRFirestoreErrorDomain"; if (!documentPath) { FSTThrowInvalidArgument(@"Document path cannot be nil."); } + if ([documentPath containsString:@"//"]) { + FSTThrowInvalidArgument(@"Invalid path (%@). Paths must not contain // in them.", documentPath); + } + [self ensureClientConfigured]; const ResourcePath path = ResourcePath::FromString(util::MakeStringView(documentPath)); return [FIRDocumentReference referenceWithPath:path firestore:self]; |