Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regex: remove parseStdRegexAsCompiledMatcher #17061

Merged
merged 1 commit into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions source/common/common/regex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ CompiledMatcherPtr Utility::parseRegex(const envoy::type::matcher::v3::RegexMatc
return std::make_unique<CompiledGoogleReMatcher>(matcher);
}

CompiledMatcherPtr Utility::parseStdRegexAsCompiledMatcher(const std::string& regex,
std::regex::flag_type flags) {
return std::make_unique<CompiledStdMatcher>(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
Expand Down
10 changes: 0 additions & 10 deletions source/common/common/regex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
12 changes: 0 additions & 12 deletions test/common/common/regex_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down