Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5f2a8878118543bfc97b64abd558e5c8e75e33f4
      
https://github.com/WebKit/WebKit/commit/5f2a8878118543bfc97b64abd558e5c8e75e33f4
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-07-20 (Mon, 20 Jul 2026)

  Changed paths:
    M Source/JavaScriptCore/runtime/JSONAtomStringCacheInlines.h

  Log Message:
  -----------
  [JSC] `JSON.parse` should create 8-bit strings for Latin1 values in a 16-bit 
input
https://bugs.webkit.org/show_bug.cgi?id=319782

Reviewed by Yusuke Suzuki.

When the input to JSON.parse is a 16-bit string (e.g. it contains a single 
emoji anywhere),
LiteralParser<char16_t> creates every value string longer than 16 characters 
via String(characters),
which is unconditionally 16-bit, even when the value itself is pure Latin1. 
Keys and values up to
16 characters already go through AtomStringImpl::add, which uses 
create8BitIfPossible.

This makes the value path use StringImpl::create8BitIfPossible as well, 
matching V8, which decides
one-byte vs two-byte per string in its JSON parser.

* Source/JavaScriptCore/runtime/JSONAtomStringCacheInlines.h:
(JSC::JSONAtomStringCache::makeJSString):

Canonical link: https://commits.webkit.org/317566@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to