Skip to content

Commit

Permalink
Ensure [[:blank:]] only matches [ \t]. Fix rust-lang#533.
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytm committed Oct 27, 2018
1 parent 488fe56 commit 63e8de1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion regex-syntax/src/hir/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ fn ascii_class(kind: &ast::ClassAsciiKind) -> &'static [(char, char)] {
X
}
Blank => {
const X: T = &[(' ', '\t')];
const X: T = &[('\t', '\t'), (' ', ' ')];
X
}
Cntrl => {
Expand Down
17 changes: 17 additions & 0 deletions tests/regression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,20 @@ ismatch!(
r"typename type\-parameter\-\d+\-\d+::.+",
"test",
false);

// See: https://github.com/rust-lang/regex/issues/533
ismatch!(
blank_matches_nothing_between_space_and_tab,
r"[[:blank:]]",
"\u{a}\u{b}\u{c}\u{d}\u{e}\u{f}\
\u{10}\u{11}\u{12}\u{13}\u{14}\u{15}\u{16}\u{17}\
\u{18}\u{19}\u{1a}\u{1b}\u{1c}\u{1d}\u{1e}\u{1f}",
false);

ismatch!(
inverted_blank_matches_everything_between_space_and_tab,
r"^[[:^blank:]]+$",
"\u{a}\u{b}\u{c}\u{d}\u{e}\u{f}\
\u{10}\u{11}\u{12}\u{13}\u{14}\u{15}\u{16}\u{17}\
\u{18}\u{19}\u{1a}\u{1b}\u{1c}\u{1d}\u{1e}\u{1f}",
true);

0 comments on commit 63e8de1

Please sign in to comment.