File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
src/tools/compiletest/src Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -1317,20 +1317,21 @@ fn expand_variables(mut value: String, config: &Config) -> String {
1317
1317
fn parse_normalize_rule ( header : & str ) -> Option < ( String , String ) > {
1318
1318
// FIXME(#126370): A colon after the header name should be mandatory, but
1319
1319
// currently is not, and there are many tests that lack the colon.
1320
- // FIXME: Support escaped double-quotes in strings.
1321
1320
let captures = static_regex ! (
1322
1321
r#"(?x) # (verbose mode regex)
1323
1322
^
1324
- [^:\s]+:?\s* # (header name followed by optional colon)
1325
- "(?<regex>[^"]*)" # "REGEX"
1326
- \s+->\s+ # ->
1327
- "(?<replacement>[^"]*)" # "REPLACEMENT"
1323
+ [^:\s]+:?\s* # (header name followed by optional colon)
1324
+ "(?<regex>(?:\\"| [^"]) *)" # "REGEX"
1325
+ \s+->\s+ # ->
1326
+ "(?<replacement>(?:\\"| [^"]) *)" # "REPLACEMENT"
1328
1327
$
1329
1328
"#
1330
1329
)
1331
1330
. captures ( header) ?;
1331
+ // The regex engine will unescape `\"` to `"`.
1332
1332
let regex = captures[ "regex" ] . to_owned ( ) ;
1333
- let replacement = captures[ "replacement" ] . to_owned ( ) ;
1333
+ // Unescape any escaped double-quotes in the replacement string.
1334
+ let replacement = captures[ "replacement" ] . replace ( r#"\""# , r#"""# ) ;
1334
1335
Some ( ( regex, replacement) )
1335
1336
}
1336
1337
Original file line number Diff line number Diff line change @@ -46,6 +46,11 @@ fn test_parse_normalize_rule() {
46
46
"something (32 bits)" ,
47
47
"something ($WORD bits)" ,
48
48
) ,
49
+ (
50
+ r#"normalize-stout-test: "\"json\"key\"" -> "\"json\"value\"""# ,
51
+ r#"\"json\"key\""# ,
52
+ r#""json"value""# ,
53
+ ) ,
49
54
] ;
50
55
51
56
for & ( input, expected_regex, expected_replacement) in good_data {
You can’t perform that action at this time.
0 commit comments