mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibJS: Disallow numerical separators in octal numbers and after '.'
This commit is contained in:
parent
32016d3924
commit
afde1821b5
Notes:
sideshowbarker
2024-07-17 23:18:56 +09:00
Author: https://github.com/davidot
Commit: afde1821b5
Pull-request: https://github.com/SerenityOS/serenity/pull/11088
Issue: https://github.com/SerenityOS/serenity/issues/11078
Reviewed-by: https://github.com/IdanHo
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/linusg ✅
2 changed files with 34 additions and 4 deletions
|
@ -654,7 +654,7 @@ Token Lexer::next()
|
|||
if (m_current_char == '.') {
|
||||
// decimal
|
||||
consume();
|
||||
while (is_ascii_digit(m_current_char) || match_numeric_literal_separator_followed_by(is_ascii_digit))
|
||||
while (is_ascii_digit(m_current_char))
|
||||
consume();
|
||||
if (m_current_char == 'e' || m_current_char == 'E')
|
||||
is_invalid_numeric_literal = !consume_exponent();
|
||||
|
@ -688,7 +688,7 @@ Token Lexer::next()
|
|||
// octal without '0o' prefix. Forbidden in 'strict mode'
|
||||
do {
|
||||
consume();
|
||||
} while (is_ascii_digit(m_current_char) || match_numeric_literal_separator_followed_by(is_ascii_digit));
|
||||
} while (is_ascii_digit(m_current_char));
|
||||
}
|
||||
} else {
|
||||
// 1...9 or period
|
||||
|
@ -700,11 +700,15 @@ Token Lexer::next()
|
|||
} else {
|
||||
if (m_current_char == '.') {
|
||||
consume();
|
||||
while (is_ascii_digit(m_current_char) || match_numeric_literal_separator_followed_by(is_ascii_digit))
|
||||
if (m_current_char == '_')
|
||||
is_invalid_numeric_literal = true;
|
||||
|
||||
while (is_ascii_digit(m_current_char) || match_numeric_literal_separator_followed_by(is_ascii_digit)) {
|
||||
consume();
|
||||
}
|
||||
}
|
||||
if (m_current_char == 'e' || m_current_char == 'E')
|
||||
is_invalid_numeric_literal = !consume_exponent();
|
||||
is_invalid_numeric_literal = is_invalid_numeric_literal || !consume_exponent();
|
||||
}
|
||||
}
|
||||
if (is_invalid_numeric_literal) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue