Skip to content

Commit

Permalink
Fix escaped backslash at end of quoted string erroneously escapes the…
Browse files Browse the repository at this point in the history
… final quote (#171)

* Fix escaped backslash at end of quoted string erroneously escapes the final quote

* Add test for escaped backslash
  • Loading branch information
MichaelMakesGames authored Dec 17, 2024
1 parent 1674c75 commit e3430c3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion stellarisdashboard/parsing/rust_parser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ fn parse_float(input: &str) -> IResult<&str, f64> {
fn parse_str(input: &str) -> IResult<&str, &str> {
preceded(
multispace0,
delimited(tag("\""), escaped(none_of("\"\\"), '\\', one_of("\"")), tag("\"")),
delimited(tag("\""), escaped(none_of("\"\\"), '\\', one_of("\"\\")), tag("\"")),
)(input)
}

Expand Down Expand Up @@ -585,6 +585,14 @@ mod tests {
parse_file(test_input).expect("Should parse");
}

#[test]
fn test_escaped_backslash() {
// from a bug report for a save that failed to parse
// narrowed down to mishandled escaped backslash at end of string
let test_input = "prefix=\"GATE \\\\\"";
parse_file(test_input).expect("Should parse");
}

#[test]
fn test_skipped_key_in_mapping() {
assert_eq!(
Expand Down

0 comments on commit e3430c3

Please sign in to comment.