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

[Merged by Bors] - Fix string to number conversion for infinity #2607

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions boa_engine/src/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ impl JsString {
(Some(b'0'), Some(b'b' | b'B')) => Some(2),
(Some(b'0'), Some(b'o' | b'O')) => Some(8),
(Some(b'0'), Some(b'x' | b'X')) => Some(16),
// Make sure that no further variants of "infinity" are parsed.
(Some(b'i' | b'I'), _) => {
return f64::NAN;
}
_ => None,
};

Expand Down Expand Up @@ -430,11 +434,7 @@ impl JsString {
return value;
}

match string {
// Handle special cases so `fast_float` does not return infinity.
"inf" | "+inf" | "-inf" => f64::NAN,
string => fast_float::parse(string).unwrap_or(f64::NAN),
}
fast_float::parse(string).unwrap_or(f64::NAN)
}

/// Abstract operation `StringToBigInt ( str )`
Expand Down