Skip to content

Commit 901aaaf

Browse files
committed
include more problematic regexes
1 parent 44911cd commit 901aaaf

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

test/issue232.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,28 @@ void tester( char const (&str)[ N0 ] )
1010
std::vector<char> s(N, '\0');
1111
std::memcpy(s.data(), str, N);
1212
boost::regex rx(s.begin(), s.end());
13-
boost::match_results<std::string::const_iterator> what;
14-
std::string where(15, 'H');
15-
bool match = boost::regex_match(where, what, rx, boost::match_default | boost::match_partial | boost::match_any | boost::match_perl);
16-
(void) match;
13+
14+
std::vector<std::string> wheres;
15+
wheres.push_back(std::string(15, 'H'));
16+
wheres.push_back("");
17+
wheres.push_back(" ");
18+
19+
// Perl-style matching
20+
for (auto const& where : wheres) {
21+
boost::match_results<std::string::const_iterator> what;
22+
bool match = boost::regex_match(where, what, rx, boost::match_default | boost::match_partial | boost::match_any | boost::match_perl);
23+
(void) match;
24+
}
25+
26+
// POSIX-style matching
27+
for (auto const& where : wheres) {
28+
try {
29+
boost::match_results<std::string::const_iterator> what;
30+
bool match = boost::regex_match(where, what, rx, boost::match_default | boost::match_partial | boost::match_any | boost::match_posix);
31+
(void) match;
32+
} catch(...) {}
33+
}
34+
1735
}
1836

1937
int main()
@@ -22,9 +40,13 @@ int main()
2240
// we keep a simple human-readable version
2341
char const str1[] = "(Y(*COMMIT)|\\K\\D|.)+";
2442
char const str2[] = "(Y(*COMMIT){||\\K\\D|||||||||\\K|||ss|||||.|\232*(?(50)\027\0204657|H)\020}\031\000.* 6.'?-i)+[L??.\000\000\000\004\000\000\000\000?..<[\000\024R]*+";
43+
char const str3[] = "(Y(*COMMIT)\xFF\x80|\\L\\K||||||||||.|||||\x84|||||\x00\x00\x10||||||.* .'?-i)[L??...-i)[L??...[\x00\x14R]*+";
44+
char const str4[] = "(Y(*COMMIT)\x96||.* .* .\\K|||\x9F||||\x9C|.|||||\x84\x99|||\x01\x00\x00\x00|||'?-i#PL\x00\x01.\x86??OMMIT)?...[\x00\x14R]*+";
2545

2646
tester(str1);
2747
tester(str2);
48+
tester(str3);
49+
tester(str4);
2850

2951
// prove that we catch certain impossible scenarios
3052

0 commit comments

Comments
 (0)