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 {
13171317fn parse_normalize_rule ( header : & str ) -> Option < ( String , String ) > {
13181318 // FIXME(#126370): A colon after the header name should be mandatory, but
13191319 // currently is not, and there are many tests that lack the colon.
1320- // FIXME: Support escaped double-quotes in strings.
13211320 let captures = static_regex ! (
13221321 r#"(?x) # (verbose mode regex)
13231322 ^
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"
13281327 $
13291328 "#
13301329 )
13311330 . captures ( header) ?;
1331+ // The regex engine will unescape `\"` to `"`.
13321332 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#"""# ) ;
13341335 Some ( ( regex, replacement) )
13351336}
13361337
Original file line number Diff line number Diff line change @@ -46,6 +46,11 @@ fn test_parse_normalize_rule() {
4646 "something (32 bits)" ,
4747 "something ($WORD bits)" ,
4848 ) ,
49+ (
50+ r#"normalize-stout-test: "\"json\"key\"" -> "\"json\"value\"""# ,
51+ r#"\"json\"key\""# ,
52+ r#""json"value""# ,
53+ ) ,
4954 ] ;
5055
5156 for & ( input, expected_regex, expected_replacement) in good_data {
You can’t perform that action at this time.
0 commit comments