@@ -21,7 +21,7 @@ lazy_static! {
2121 Regex :: new( r"^%[xX][a-zA-Z0-9]*$" ) . unwrap( ) ;
2222 // Documented in `Escape sequences` in lexcompatibility.m
2323 static ref RE_LEX_ESC_LITERAL : Regex =
24- Regex :: new( r"^(([xuU][[:xdigit:]])|[[:digit:]]|[afnrtv\\]|[pP]|[dDsSwW]|[AbBz ])" ) . unwrap( ) ;
24+ Regex :: new( r"^(([xuU][[:xdigit:]])|[[:digit:]]|[afnrtv\\]|[pP]|[dDsSwW]|[Az ])" ) . unwrap( ) ;
2525 // Vertical line separators.
2626 static ref RE_LINE_SEP : Regex = Regex :: new( r"[\p{Pattern_White_Space}&&[\p{Zl}\p{Zp}\n\r\v]]" ) . unwrap( ) ;
2727 static ref RE_LEADING_LINE_SEPS : Regex = Regex :: new( r"^[\p{Pattern_White_Space}&&[\p{Zl}\p{Zp}\n\r\v]]*" ) . unwrap( ) ;
@@ -490,7 +490,7 @@ where
490490 /// XBD File Format Notation ( '\\', '\a', '\b', '\f' , '\n', '\r', '\t', '\v' ).
491491 ///
492492 /// Meaning: The character 'c', unchanged.
493- fn unescape ( re : Cow < str > ) -> Cow < str > {
493+ fn unescape < ' b > ( re : Cow < ' b , str > , regex_options : & ' _ RegexOptions ) -> Cow < ' b , str > {
494494 // POSIX lex has two layers of escaping, there are escapes for the regular
495495 // expressions themselves and the escapes which get handled by lex directly.
496496 // We can find what the `regex` crate needs to be escaped with `is_meta_character`.
@@ -539,7 +539,15 @@ where
539539 let mut last_pos = 0 ;
540540
541541 ' outer: while let Some ( ( i, s, j, c) ) = cursor {
542- if regex_syntax:: is_meta_character ( c) || RE_LEX_ESC_LITERAL . is_match ( s) {
542+ if c == 'b' {
543+ unescaped. push_str ( & re_str[ last_pos..i] ) ;
544+ unescaped. push_str ( if regex_options. posix_escapes {
545+ "\\ x08"
546+ } else {
547+ "\\ b"
548+ } ) ;
549+ last_pos = j + 1 ;
550+ } else if regex_syntax:: is_meta_character ( c) || RE_LEX_ESC_LITERAL . is_match ( s) {
543551 // For both meta characters and literals we want to push the entire substring
544552 // up to and including the c match back into the string still escaped.
545553 unescaped. push_str ( & re_str[ last_pos..j + c. len_utf8 ( ) ] ) ;
@@ -570,7 +578,7 @@ where
570578 Cow :: from ( unescaped)
571579 }
572580
573- Ok ( ( vec ! [ ] , unescape ( Cow :: from ( re_str) ) ) )
581+ Ok ( ( vec ! [ ] , unescape ( Cow :: from ( re_str) , & self . regex_options ) ) )
574582 } else {
575583 match re_str. find ( '>' ) {
576584 None => Err ( self . mk_error ( LexErrorKind :: InvalidStartState , off) ) ,
0 commit comments