Skip to content

Commit

Permalink
Merge pull request #124 from google/oss_fixes
Browse files Browse the repository at this point in the history
strings: fix invalid access with UTF8 verification, ensure absl::string_view compatibility
  • Loading branch information
kyessenov authored Jun 28, 2021
2 parents ebcffc2 + db9e3fa commit 128f215
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
3 changes: 3 additions & 0 deletions base/unilib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ namespace UniLib {

// Detects whether a string is valid UTF-8.
bool IsStructurallyValid(absl::string_view str) {
if (str.size() == 0) {
return true;
}
const char *s = &str[0];
const char *const sEnd = s + str.length();
while (s < sEnd) {
Expand Down
42 changes: 42 additions & 0 deletions bazel/abseil.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Force internal versions of std classes per
# https://abseil.io/docs/cpp/guides/options
diff --git a/absl/base/options.h b/absl/base/options.h
index 230bf1e..6e1b9e5 100644
--- a/absl/base/options.h
+++ b/absl/base/options.h
@@ -100,7 +100,7 @@
// User code should not inspect this macro. To check in the preprocessor if
// absl::any is a typedef of std::any, use the feature macro ABSL_USES_STD_ANY.

-#define ABSL_OPTION_USE_STD_ANY 2
+#define ABSL_OPTION_USE_STD_ANY 0


// ABSL_OPTION_USE_STD_OPTIONAL
@@ -127,7 +127,7 @@
// absl::optional is a typedef of std::optional, use the feature macro
// ABSL_USES_STD_OPTIONAL.

-#define ABSL_OPTION_USE_STD_OPTIONAL 2
+#define ABSL_OPTION_USE_STD_OPTIONAL 0


// ABSL_OPTION_USE_STD_STRING_VIEW
@@ -154,7 +154,7 @@
// absl::string_view is a typedef of std::string_view, use the feature macro
// ABSL_USES_STD_STRING_VIEW.

-#define ABSL_OPTION_USE_STD_STRING_VIEW 2
+#define ABSL_OPTION_USE_STD_STRING_VIEW 0

// ABSL_OPTION_USE_STD_VARIANT
//
@@ -180,7 +180,7 @@
// absl::variant is a typedef of std::variant, use the feature macro
// ABSL_USES_STD_VARIANT.

-#define ABSL_OPTION_USE_STD_VARIANT 2
+#define ABSL_OPTION_USE_STD_VARIANT 0


// ABSL_OPTION_USE_INLINE_NAMESPACE
2 changes: 2 additions & 0 deletions bazel/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ def base_deps():
"""Base evaluator and test dependencies."""
http_archive(
name = "com_google_absl",
patches = ["//bazel:abseil.patch"],
patch_args = ["-p1"],
strip_prefix = "abseil-cpp-master",
urls = ["https://github.com/abseil/abseil-cpp/archive/master.zip"],
)
Expand Down
2 changes: 1 addition & 1 deletion eval/public/structs/cel_proto_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ absl::optional<const google::protobuf::Message*> MessageFromValue(const CelValue
if (!result.has_value()) {
return {};
}
(*fields)[key] = field_value;
(*fields)[std::string(key)] = field_value;
}
return json_struct;
}
Expand Down

0 comments on commit 128f215

Please sign in to comment.