Skip to content

Commit

Permalink
Fix dollar sign parsing in URLs (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
PgBiel authored Sep 27, 2024
1 parent 99e2c6c commit f1067e2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,12 @@ Martin}}"#;
assert_eq!(
e.to_biblatex_string(),
"@online{finextraFedGovernorChallenges2019,\nauthor = {FinExtra},\ndate = {2019-12-18},\nfile = {C:\\\\Users\\\\mhaug\\\\Zotero\\\\storage\\\\VY9LAKFE\\\\fed-governor-challenges-facebooks-libra-project.html},\ntitle = {Fed {Governor} Challenges {Facebook}'s {Libra} Project},\nurl = {https://www.finextra.com/newsarticle/34986/fed-governor-challenges-facebooks-libra-project},\nurldate = {2020-08-22},\n}"
)
);

// Test URLs with math and backslashes
let e = bibliography.get("weirdUrl2023").unwrap();
assert_eq!(e.url().unwrap(), r#"example.com?A=$B\%\{}"#);
assert_eq!(e.doi().unwrap(), r#"example.com?A=$B\%\{}"#);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<'s> ContentParser<'s> {
let sequence = self.backslash()?;
self.current_chunk.get_mut().push_str(&sequence)
}
'$' => {
'$' if !self.verb_field => {
self.turnaround(depth);
let math = self.math()?;
self.result.push(math);
Expand Down
12 changes: 12 additions & 0 deletions tests/libra.bib
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,15 @@ @online{rodriguezMeetMorganBeller2019
file = {C\:\\Users\\mhaug\\Zotero\\storage\\HGBKSYXN\\facebook-libra-partly-created-by-female-engineer-morgan-beller.html},
langid = {english}
}

@article{weirdUrl2023,
author = {W. Url},
journal = {Journal},
number = {1},
title = {Title},
volume = {2},
year = {2023},
comment = {3\$},
url = {example.com?A=$B\%\\\{\}},
doi = {example.com?A=$B\%\\\{\}},
}

0 comments on commit f1067e2

Please sign in to comment.