aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/API/FSTUserDataConverter.mm
diff options
context:
space:
mode:
authorGravatar Rich Gowman <rgowman@google.com>2018-06-12 10:27:17 -0400
committerGravatar Rich Gowman <rgowman@google.com>2018-06-12 10:27:17 -0400
commitcf2899a085f7ceca3fad2d1fb5336be25cecd7ff (patch)
tree38c835a29fcda279c8dd220781d2b5c726da307f /Firestore/Source/API/FSTUserDataConverter.mm
parent1597765af8c897ab73d21d6d404f8eeede7890b1 (diff)
parent9307f4893008f7d6cf9473e906d4c896546c5c8c (diff)
Merge remote-tracking branch 'origin/master' into rsgowman/protobuf_cpp
Also "fixed" BadFieldValueTagWithOtherValidTagsPresent test by changing 'false' to 'true'. Details: Depending on the version of nanopb, nanopb would explicitly encode 'false', which shouldn't be done in proto3. When it's explicitly encoded, the test worked properly. But when it was (properly) dropped, the invalid tag is the only field that's actually encoded, thus violating the assumptions of the test, leading to a test failure. s/false/true fixes it, as now the boolean_value field is (properly) encoded regardless of version.
Diffstat (limited to 'Firestore/Source/API/FSTUserDataConverter.mm')
-rw-r--r--Firestore/Source/API/FSTUserDataConverter.mm19
1 files changed, 11 insertions, 8 deletions
diff --git a/Firestore/Source/API/FSTUserDataConverter.mm b/Firestore/Source/API/FSTUserDataConverter.mm
index 44e46da..d73a870 100644
--- a/Firestore/Source/API/FSTUserDataConverter.mm
+++ b/Firestore/Source/API/FSTUserDataConverter.mm
@@ -17,6 +17,7 @@
#import "Firestore/Source/API/FSTUserDataConverter.h"
#include <memory>
+#include <string>
#include <utility>
#include <vector>
@@ -41,6 +42,7 @@
#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
#include "absl/memory/memory.h"
+#include "absl/strings/match.h"
namespace util = firebase::firestore::util;
using firebase::firestore::model::ArrayTransform;
@@ -55,7 +57,7 @@ using firebase::firestore::model::TransformOperation;
NS_ASSUME_NONNULL_BEGIN
-static NSString *const RESERVED_FIELD_DESIGNATOR = @"__";
+static const char *RESERVED_FIELD_DESIGNATOR = "__";
#pragma mark - FSTParsedSetData
@@ -277,7 +279,7 @@ typedef NS_ENUM(NSInteger, FSTUserDataSource) {
arrayElement:NO
fieldTransforms:_fieldTransforms
fieldMask:_fieldMask];
- [context validatePathSegment:fieldName];
+ [context validatePathSegment:util::MakeStringView(fieldName)];
return context;
}
@@ -334,15 +336,16 @@ typedef NS_ENUM(NSInteger, FSTUserDataSource) {
if (_path == nullptr) {
return;
}
- for (const auto &segment : *_path) {
- [self validatePathSegment:util::WrapNSStringNoCopy(segment)];
+ for (const std::string &segment : *_path) {
+ [self validatePathSegment:segment];
}
}
-- (void)validatePathSegment:(NSString *)segment {
- if ([self isWrite] && [segment hasPrefix:RESERVED_FIELD_DESIGNATOR] &&
- [segment hasSuffix:RESERVED_FIELD_DESIGNATOR]) {
- FSTThrowInvalidArgument(@"Document fields cannot begin and end with %@%@",
+- (void)validatePathSegment:(absl::string_view)segment {
+ absl::string_view designator{RESERVED_FIELD_DESIGNATOR};
+ if ([self isWrite] && absl::StartsWith(segment, designator) &&
+ absl::EndsWith(segment, designator)) {
+ FSTThrowInvalidArgument(@"Document fields cannot begin and end with %s%@",
RESERVED_FIELD_DESIGNATOR, [self fieldDescription]);
}
}