diff --git a/boa_engine/src/syntax/lexer/comment.rs b/boa_engine/src/syntax/lexer/comment.rs index 1e5ecdf367..a34bce9fbc 100644 --- a/boa_engine/src/syntax/lexer/comment.rs +++ b/boa_engine/src/syntax/lexer/comment.rs @@ -34,12 +34,13 @@ impl Tokenizer for SingleLineComment { let _timer = Profiler::global().start_event("SingleLineComment", "Lexing"); // Skip either to the end of the line or to the end of the input - while let Some(ch) = cursor.peek()? { - if ch == b'\n' || ch == b'\r' { - break; - } - // Consume char. - cursor.next_byte()?.expect("Comment character vanished"); + while let Some(ch) = cursor.peek_char()? { + let tried_ch = char::try_from(ch); + match tried_ch { + Ok(c) if c == '\r' || c == '\n' || c == '\u{2028}' || c == '\u{2029}' => break, + _ => {} + }; + cursor.next_char().expect("Comment character vanished"); } Ok(Token::new( TokenKind::Comment,