mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: fix backslash doubling in attribute string args (#9175)
This commit is contained in:
parent
053d6870d2
commit
6048d0e974
@ -1,3 +1,8 @@
|
||||
struct AttrsWithEscpaedStringArgs {
|
||||
dollar string [foo: '\$var']
|
||||
double_bs string [bar: '\\baz']
|
||||
}
|
||||
|
||||
[deprecated: 'use bar() instead']
|
||||
[foo: bar]
|
||||
[if debug; inline]
|
||||
|
@ -29,9 +29,7 @@ pub fn (attr Attr) str() string {
|
||||
if attr.arg.len > 0 {
|
||||
s += ': '
|
||||
if attr.is_string_arg {
|
||||
mut a := attr.arg.replace('\\', '\\\\')
|
||||
// FIXME: other escapes e.g. \r\n
|
||||
a = a.replace("'", "\\'")
|
||||
a := attr.arg.replace("'", "\\'")
|
||||
s += "'$a'"
|
||||
} else {
|
||||
s += attr.arg
|
||||
|
Loading…
Reference in New Issue
Block a user