LibJS: Don't infinite loop on unknown console.log formatting specifiers

This commit is contained in:
Andreas Kling 2024-09-26 07:42:49 +02:00 committed by Andreas Kling
parent 84351dfa51
commit ef9208047d
Notes: github-actions[bot] 2024-09-26 08:15:20 +00:00
3 changed files with 9 additions and 1 deletions

View file

@ -0,0 +1 @@
PASS (didn't hang)

View file

@ -0,0 +1,7 @@
<script src="../include.js"></script>
<script>
test(() => {
console.log("%z%z", 1, 2);
println("PASS (didn't hang)");
});
</script>

View file

@ -818,7 +818,7 @@ ThrowCompletionOr<MarkedVector<Value>> ConsoleClient::formatter(MarkedVector<Val
auto find_specifier = [](StringView target) -> Optional<StringView> { auto find_specifier = [](StringView target) -> Optional<StringView> {
size_t start_index = 0; size_t start_index = 0;
while (start_index < target.length()) { while (start_index < target.length()) {
auto maybe_index = target.find('%'); auto maybe_index = target.find('%', start_index);
if (!maybe_index.has_value()) if (!maybe_index.has_value())
return {}; return {};