Skip to content

Commit 9f666ad

Browse files
authored
v.util: fix handling of "start \u005c${...} end" in cgen (fix #25304) (#25306)
1 parent 0e4078f commit 9f666ad

5 files changed

Lines changed: 20 additions & 0 deletions
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
start
2+
done
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
println('start')
2+
b := 'Hello world!\u004azz\u005cXYZ'
3+
a := 'zzz\u005c${')}}));builtin__println(b);//'}QWE'
4+
_ := a
5+
_ := b
6+
println('done')
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
start
2+
done
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
println('start')
2+
b := 'Hello world!'
3+
c := '\u005c${')}}));builtin__println(b);//'}'
4+
_ := b
5+
_ := c
6+
println('done')

‎vlib/v/util/quote.v‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ pub fn smart_quote(str string, raw bool) string {
114114
skip_next = true
115115
continue
116116
}
117+
// protect against '\u005c${...}'
118+
if next == 0 && current == backslash {
119+
continue
120+
}
117121
if !raw {
118122
if current == `$` {
119123
if last == backslash {

0 commit comments

Comments
 (0)