mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
LibJS: Don't parse numeric literal containing 8 or 9 as octal
If the value has a leading zero (allowed in non-strict mode) but contains the digits 8 or 9 it can't be an octal number.
This commit is contained in:
parent
b4e51249e9
commit
b5bd05b717
Notes:
sideshowbarker
2024-07-19 01:40:56 +09:00
Author: https://github.com/linusg
Commit: b5bd05b717
Pull-request: https://github.com/SerenityOS/serenity/pull/3863
Reviewed-by: https://github.com/awesomekling
2 changed files with 3 additions and 1 deletions
|
@ -86,7 +86,8 @@ double Token::double_value() const
|
|||
return static_cast<double>(strtoul(value_string.characters() + 2, nullptr, 2));
|
||||
} else if (isdigit(value_string[1])) {
|
||||
// also octal, but syntax error in strict mode
|
||||
return static_cast<double>(strtoul(value_string.characters() + 1, nullptr, 8));
|
||||
if (!m_value.contains('8') && !m_value.contains('9'))
|
||||
return static_cast<double>(strtoul(value_string.characters() + 1, nullptr, 8));
|
||||
}
|
||||
}
|
||||
return strtod(value_string.characters(), nullptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue