summaryrefslogtreecommitdiff
path: root/chromium/third_party/liburlpattern/tokenize_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/liburlpattern/tokenize_unittest.cc')
-rw-r--r--chromium/third_party/liburlpattern/tokenize_unittest.cc38
1 files changed, 35 insertions, 3 deletions
diff --git a/chromium/third_party/liburlpattern/tokenize_unittest.cc b/chromium/third_party/liburlpattern/tokenize_unittest.cc
index ac37983488a..46900e40226 100644
--- a/chromium/third_party/liburlpattern/tokenize_unittest.cc
+++ b/chromium/third_party/liburlpattern/tokenize_unittest.cc
@@ -288,9 +288,9 @@ TEST(TokenizeTest, RegexWithTrailingEscapedChar) {
}
TEST(TokenizeTest, RegexWithEscapedInvalidChar) {
- // Use a single byte invalid character since the escape only applies to the
- // next byte character.
- RunTokenizeTest("(\\\xff)",
+ // Use a valid UTF-8 sequence (encoding of U+00A2) that encodes a non-ASCII
+ // character.
+ RunTokenizeTest("(\\\xc2\xa2)",
absl::InvalidArgumentError("Invalid non-ASCII character"));
}
@@ -477,4 +477,36 @@ TEST(TokenizeTest, LenientPolicyRegexWithCaptureGroup) {
RunTokenizeTest("(foo(bar))", expected_tokens, TokenizePolicy::kLenient);
}
+TEST(TokenizeTest, InvalidUtf8) {
+ RunTokenizeTest("hello\xcdworld", absl::InvalidArgumentError(
+ "Invalid UTF-8 codepoint at index 5."));
+}
+
+TEST(TokenizeTest, InvalidUtf8Escaped) {
+ RunTokenizeTest(
+ "hello\\\xcdworld",
+ absl::InvalidArgumentError("Invalid UTF-8 codepoint at index 7."));
+}
+
+TEST(TokenizeTest, InvalidUtf8InName) {
+ RunTokenizeTest(
+ "/:foo:hello\xcdworld",
+ absl::InvalidArgumentError("Invalid UTF-8 codepoint at index 11."));
+}
+
+TEST(TokenizeTest, InvalidUtf8InRegexGroup) {
+ RunTokenizeTest("(foo\xcd)", absl::InvalidArgumentError(
+ "Invalid UTF-8 codepoint at index 4."));
+}
+
+TEST(TokenizeTest, InvalidUtf8EscapedInRegexGroup) {
+ RunTokenizeTest("(foo\\\xcd)", absl::InvalidArgumentError(
+ "Invalid UTF-8 codepoint at index 6."));
+}
+
+TEST(TokenizeTest, InvalidUtf8InNestedRegexGroup) {
+ RunTokenizeTest("(foo(\xcd))", absl::InvalidArgumentError(
+ "Invalid UTF-8 codepoint at index 6."));
+}
+
} // namespace liburlpattern