mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
scanner: fix single backslash in raw string (#10890)
This commit is contained in:
parent
b537c9f624
commit
ed234188b7
@ -292,7 +292,7 @@ fn (mut ad AnchorData) add_link_targets(line_number int, line string) {
|
||||
}
|
||||
}
|
||||
} 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) }
|
||||
res := re.find_all_str(line)
|
||||
|
||||
|
@ -1126,7 +1126,8 @@ fn (mut s Scanner) ident_string() string {
|
||||
c := s.text[s.pos]
|
||||
prevc := s.text[s.pos - 1]
|
||||
// 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
|
||||
break
|
||||
}
|
||||
|
3
vlib/v/tests/raw_string_test.v
Normal file
3
vlib/v/tests/raw_string_test.v
Normal file
@ -0,0 +1,3 @@
|
||||
fn test_raw_string_backslash() {
|
||||
assert r'\' == r'\'
|
||||
}
|
Loading…
Reference in New Issue
Block a user