Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lexing escapes in string literal and minor refactor #1079

Merged
merged 23 commits into from
Jan 20, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor refactor
  • Loading branch information
jevancc committed Jan 19, 2021
commit b9d7b02d902d91e7aaca13767be35b105db55f12
9 changes: 4 additions & 5 deletions boa/src/syntax/lexer/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ impl StringLiteral {
'\\' => buf.push(0x005C /* \ */),
'0' if cursor
.peek()?
.and_then(|next_byte| char::try_from(next_byte).ok())
.filter(|next_ch| next_ch.is_digit(10))
.filter(|next_byte| (b'0'..=b'9').contains(next_byte))
.is_none() =>
{
buf.push(0x0000 /* NULL */)
Expand Down Expand Up @@ -303,14 +302,14 @@ impl StringLiteral {
// Grammar: ZeroToThree OctalDigit
// Grammar: FourToSeven OctalDigit
if let Some(byte) = cursor.peek()? {
if (b'0'..b'8').contains(&byte) {
if (b'0'..=b'7').contains(&byte) {
let _ = cursor.next_byte()?;
code_point = (code_point * 8) + (byte - b'0') as u32;

if (b'0'..b'4').contains(&init_byte) {
if (b'0'..=b'3').contains(&init_byte) {
// Grammar: ZeroToThree OctalDigit OctalDigit
if let Some(byte) = cursor.peek()? {
if (b'0'..b'8').contains(&byte) {
if (b'0'..=b'7').contains(&byte) {
let _ = cursor.next_byte()?;
code_point = (code_point * 8) + (byte - b'0') as u32;
}
Expand Down