Skip to content
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
1 change: 1 addition & 0 deletions stl/inc/regex
Original file line number Diff line number Diff line change
Expand Up @@ -4348,6 +4348,7 @@ bool _Parser<_FwdIt, _Elem, _RxTraits>::_IsIdentityEscape(bool _In_character_cla
return true;
case _Meta_dot:
case _Meta_lsq:
case _Meta_rsq:
case _Meta_star:
case _Meta_caret:
case _Meta_dlr:
Expand Down
13 changes: 8 additions & 5 deletions tests/std/tests/GH_005244_regex_escape_sequences/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,13 @@ void test_gh_5244_atomescape_posix_common(syntax_option_type option) {
check_atomescape_identityescape("^", option);
check_atomescape_identityescape("$", option);

// Even though [ is special, ] is not,
// so the interpretation of the escape sequence \] is undefined
// according to the POSIX standard referenced in the C++ standard.
// But we treat \] as an identity escape in line with
// more recent versions of the POSIX standard.
check_atomescape_identityescape("]", option);

// Sections on "BRE Special Characters" and "ERE Special Characters":
// escaping ordinary characters is undefined -> reject
g_regexTester.should_throw(R"(\B)", error_escape, option);
Expand All @@ -478,9 +485,6 @@ void test_gh_5244_atomescape_posix_common(syntax_option_type option) {
g_regexTester.should_throw(R"(\W)", error_escape, option);
g_regexTester.should_throw(R"(\s)", error_escape, option);
g_regexTester.should_throw(R"(\S)", error_escape, option);

// while [ is special, ] is not
g_regexTester.should_throw(R"(\])", error_escape, option);
}

void test_gh_5244_atomescape_posix_not_awk(syntax_option_type option) {
Expand Down Expand Up @@ -519,8 +523,6 @@ void test_gh_5244_atomescape_basic_or_grep(syntax_option_type option) {
}

void test_gh_5244_atomescape_extended_egrep_awk(syntax_option_type option) {
test_gh_5244_atomescape_posix_common(option);

// check that the parser accepts escaped characters
// that are only special in extended regexes
check_atomescape_identityescape("+", option);
Expand Down Expand Up @@ -552,6 +554,7 @@ void test_gh_5244_atomescape_extended_or_egrep(syntax_option_type option) {

void test_gh_5244_atomescape_awk() {
test_gh_5244_atomescape_extended_egrep_awk(awk);
test_gh_5244_atomescape_posix_common(awk);

// awk-only escapes
check_atomescape_controlescape("\a", "a", awk);
Expand Down