From 6048d0e974d2b7536f9c0bf112b7b2c7fdaa5401 Mon Sep 17 00:00:00 2001 From: Lukas Neubert Date: Sun, 7 Mar 2021 08:44:58 +0100 Subject: [PATCH] fmt: fix backslash doubling in attribute string args (#9175) --- vlib/v/fmt/tests/attrs_keep.vv | 5 +++++ vlib/v/table/attr.v | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/vlib/v/fmt/tests/attrs_keep.vv b/vlib/v/fmt/tests/attrs_keep.vv index da2606da89..cad488cec8 100644 --- a/vlib/v/fmt/tests/attrs_keep.vv +++ b/vlib/v/fmt/tests/attrs_keep.vv @@ -1,3 +1,8 @@ +struct AttrsWithEscpaedStringArgs { + dollar string [foo: '\$var'] + double_bs string [bar: '\\baz'] +} + [deprecated: 'use bar() instead'] [foo: bar] [if debug; inline] diff --git a/vlib/v/table/attr.v b/vlib/v/table/attr.v index b66572e2e4..106df986d9 100644 --- a/vlib/v/table/attr.v +++ b/vlib/v/table/attr.v @@ -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