scanner: fix single backslash in raw string (#10890)
parent
b537c9f624
commit
ed234188b7
|
@ -292,7 +292,7 @@ fn (mut ad AnchorData) add_link_targets(line_number int, line string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
query := r'<a\s*id=["\'](?P<link>[a-z0-9\-\_\x7f-\uffff]+)["\']\s*/>'
|
query := '<a\\s*id=["\'](?P<link>[a-z0-9\\-\\_\\x7f-\\uffff]+)["\']\\s*/>'
|
||||||
mut re := regex.regex_opt(query) or { panic(err) }
|
mut re := regex.regex_opt(query) or { panic(err) }
|
||||||
res := re.find_all_str(line)
|
res := re.find_all_str(line)
|
||||||
|
|
||||||
|
|
|
@ -1126,7 +1126,8 @@ fn (mut s Scanner) ident_string() string {
|
||||||
c := s.text[s.pos]
|
c := s.text[s.pos]
|
||||||
prevc := s.text[s.pos - 1]
|
prevc := s.text[s.pos - 1]
|
||||||
// end of string
|
// end of string
|
||||||
if c == s.quote && (prevc != slash || (prevc == slash && s.text[s.pos - 2] == slash)) {
|
if c == s.quote
|
||||||
|
&& (is_raw || prevc != slash || (prevc == slash && s.text[s.pos - 2] == slash)) {
|
||||||
// handle '123\\' slash at the end
|
// handle '123\\' slash at the end
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
fn test_raw_string_backslash() {
|
||||||
|
assert r'\' == r'\'
|
||||||
|
}
|
Loading…
Reference in New Issue