diff --git a/source/common/common/regex.cc b/source/common/common/regex.cc index deeef41aa12b..1f1aa4cc4a57 100644 --- a/source/common/common/regex.cc +++ b/source/common/common/regex.cc @@ -127,11 +127,6 @@ CompiledMatcherPtr Utility::parseRegex(const envoy::type::matcher::v3::RegexMatc return std::make_unique(matcher); } -CompiledMatcherPtr Utility::parseStdRegexAsCompiledMatcher(const std::string& regex, - std::regex::flag_type flags) { - return std::make_unique(parseStdRegex(regex, flags)); -} - std::regex Utility::parseStdRegex(const std::string& regex, std::regex::flag_type flags) { // TODO(zuercher): In the future, PGV (https://github.com/envoyproxy/protoc-gen-validate) // annotations may allow us to remove this in favor of direct validation of regular diff --git a/source/common/common/regex.h b/source/common/common/regex.h index 2fdcd52ebc1c..e360cab01b96 100644 --- a/source/common/common/regex.h +++ b/source/common/common/regex.h @@ -26,16 +26,6 @@ class Utility { static std::regex parseStdRegex(const std::string& regex, std::regex::flag_type flags = std::regex::optimize); - /** - * Construct an std::regex compiled regex matcher. - * - * TODO(mattklein123): In general this is only currently used in deprecated code paths and can be - * removed once all of those code paths are removed. - */ - static CompiledMatcherPtr - parseStdRegexAsCompiledMatcher(const std::string& regex, - std::regex::flag_type flags = std::regex::optimize); - /** * Construct a compiled regex matcher from a match config. */ diff --git a/test/common/common/regex_test.cc b/test/common/common/regex_test.cc index 5d33d23bafbd..24cd3efc555d 100644 --- a/test/common/common/regex_test.cc +++ b/test/common/common/regex_test.cc @@ -17,9 +17,6 @@ TEST(Utility, ParseStdRegex) { EXPECT_THROW_WITH_REGEX(Utility::parseStdRegex("(+invalid)"), EnvoyException, "Invalid regex '\\(\\+invalid\\)': .+"); - EXPECT_THROW_WITH_REGEX(Utility::parseStdRegexAsCompiledMatcher("(+invalid)"), EnvoyException, - "Invalid regex '\\(\\+invalid\\)': .+"); - { std::regex regex = Utility::parseStdRegex("x*"); EXPECT_NE(0, regex.flags() & std::regex::optimize); @@ -30,15 +27,6 @@ TEST(Utility, ParseStdRegex) { EXPECT_NE(0, regex.flags() & std::regex::icase); EXPECT_EQ(0, regex.flags() & std::regex::optimize); } - - { - // Regression test to cover high-complexity regular expressions that throw on std::regex_match. - // Note that not all std::regex_match implementations will throw when matching against the - // expression below, but at least clang 9.0.0 under linux does. - auto matcher = Utility::parseStdRegexAsCompiledMatcher( - "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"); - EXPECT_FALSE(matcher->match("0")); - } } TEST(Utility, ParseRegex) {