Merge pull request #250 from ehuss/reject-del

0.5: Reject 0x7f (DEL) in strings.
This commit is contained in:
Alex Crichton 2018-07-11 09:04:29 -05:00 committed by GitHub
commit 4971310a96
2 changed files with 4 additions and 2 deletions

View file

@ -331,7 +331,7 @@ impl<'a> Tokenizer<'a> {
fn literal_string(&mut self, start: usize) -> Result<Token<'a>, Error> { fn literal_string(&mut self, start: usize) -> Result<Token<'a>, Error> {
self.read_string('\'', start, &mut |_me, val, _multi, i, ch| { self.read_string('\'', start, &mut |_me, val, _multi, i, ch| {
if ch == '\u{09}' || ('\u{20}' <= ch && ch <= '\u{10ffff}') { if ch == '\u{09}' || ('\u{20}' <= ch && ch <= '\u{10ffff}' && ch != '\u{7f}') {
val.push(ch); val.push(ch);
Ok(()) Ok(())
} else { } else {
@ -373,7 +373,7 @@ impl<'a> Tokenizer<'a> {
} }
Ok(()) Ok(())
} }
ch if '\u{20}' <= ch && ch <= '\u{10ffff}' => { ch if '\u{20}' <= ch && ch <= '\u{10ffff}' && ch != '\u{7f}' => {
val.push(ch); val.push(ch);
Ok(()) Ok(())
} }

View file

@ -11,4 +11,6 @@ fn bad() {
bad("a = 1_"); bad("a = 1_");
bad("''"); bad("''");
bad("a = 9e99999"); bad("a = 9e99999");
bad("a = \"\u{7f}\"");
bad("a = '\u{7f}'");
} }