aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2019-03-20 14:07:50 -0500
committerGitHub <noreply@github.com>2019-03-20 14:07:50 -0500
commitd729bf9c53fcfe8f1e5506a938b88d81526b55a4 (patch)
tree3b1da285129b52ba02fb4995b442768e9cb76ea0 /src
parentdbdcc9ccc4233b4a7b3a1ce42d49fb863f1c903a (diff)
parenta92266db70f481f52f3e14e857e1ead300b1f473 (diff)
downloadmilf-rs-d729bf9c53fcfe8f1e5506a938b88d81526b55a4.tar.gz
milf-rs-d729bf9c53fcfe8f1e5506a938b88d81526b55a4.zip
Merge pull request #294 from tmiasko/ml-delim
Fix parsing of repeated delimiters inside multi-line strings
Diffstat (limited to 'src')
-rw-r--r--src/tokens.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/tokens.rs b/src/tokens.rs
index 064c804..6413ce1 100644
--- a/src/tokens.rs
+++ b/src/tokens.rs
@@ -336,11 +336,14 @@ impl<'a> Tokenizer<'a> {
}
Some((i, ch)) if ch == delim => {
if multiline {
- for _ in 0..2 {
- if !self.eatc(delim) {
- val.push(delim);
- continue 'outer;
- }
+ if !self.eatc(delim) {
+ val.push(delim);
+ continue 'outer;
+ }
+ if !self.eatc(delim) {
+ val.push(delim);
+ val.push(delim);
+ continue 'outer;
}
}
return Ok(String {
@@ -630,6 +633,7 @@ mod tests {
t(r#""\"a""#, "\"a", false);
t("\"\"\"\na\"\"\"", "a", true);
t("\"\"\"\n\"\"\"", "", true);
+ t(r#""""a\"""b""""#, "a\"\"\"b", true);
err(r#""\a"#, Error::InvalidEscape(2, 'a'));
err("\"\\\n", Error::InvalidEscape(2, '\n'));
err("\"\\\r\n", Error::InvalidEscape(2, '\n'));