diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-08-30 20:20:58 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-30 18:43:09 +0200 |
commit | 206bc01f81f2efe0e8fb237149e3ce0556602e4b (patch) | |
tree | 1d67f4a80e01178beba33ee896d8ee487e5ec036 | |
parent | 0de35db0f19cad50dfb35660d4d860f7a55649cc (diff) | |
download | serenity-206bc01f81f2efe0e8fb237149e3ce0556602e4b.zip |
LibRegex: Allow null bytes in pattern
That check was rather pointless as the input is a StringView which knows
its own bounds.
Fixes #9686.
-rw-r--r-- | Tests/LibRegex/Regex.cpp | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibRegex/RegexLexer.cpp | 5 |
2 files changed, 2 insertions, 4 deletions
diff --git a/Tests/LibRegex/Regex.cpp b/Tests/LibRegex/Regex.cpp index d7630fb25d..97c201bb96 100644 --- a/Tests/LibRegex/Regex.cpp +++ b/Tests/LibRegex/Regex.cpp @@ -660,6 +660,7 @@ TEST_CASE(ECMA262_match) { "[\\0]"sv, "\0"sv, true, ECMAScriptFlags::BrowserExtended }, { "[\\0]"sv, "\0"sv, true, combine_flags(ECMAScriptFlags::Unicode, ECMAScriptFlags::BrowserExtended) }, { "[\\01]"sv, "\1"sv, true, ECMAScriptFlags::BrowserExtended }, + { "(\0|a)"sv, "a"sv, true }, // #9686, Should allow null bytes in pattern }; // clang-format on diff --git a/Userland/Libraries/LibRegex/RegexLexer.cpp b/Userland/Libraries/LibRegex/RegexLexer.cpp index 69b2b4d345..671e2cb4fa 100644 --- a/Userland/Libraries/LibRegex/RegexLexer.cpp +++ b/Userland/Libraries/LibRegex/RegexLexer.cpp @@ -109,7 +109,7 @@ Token Lexer::next() } }; - while (m_index <= m_input.length()) { + while (m_index < m_input.length()) { auto ch = peek(); if (ch == '(') return emit_token(TokenType::LeftParen); @@ -175,9 +175,6 @@ Token Lexer::next() } } - if (ch == '\0') - break; - return emit_token(TokenType::Char); } |