From 23f8320148672310ff71aa3ef2b6c3ac86d47ede Mon Sep 17 00:00:00 2001 From: Gil Date: Tue, 22 May 2018 21:39:45 -0700 Subject: 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. --- Firestore/Source/API/FIRFirestore.mm | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Firestore') 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]; -- cgit v1.2.3