Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 47164fceaef424c680a823501af79ded59f02c81
      
https://github.com/WebKit/WebKit/commit/47164fceaef424c680a823501af79ded59f02c81
  Author: Alex Christensen <[email protected]>
  Date:   2026-02-04 (Wed, 04 Feb 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/url/percent-encoding.window-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/url/resources/percent-encoding.json
    M Source/WebCore/PAL/pal/text/TextCodecICU.cpp

  Log Message:
  -----------
  URL query percent encoding is incorrect
https://bugs.webkit.org/show_bug.cgi?id=306742
rdar://169566553

Reviewed by Anne van Kesteren.

We have used ucnv_setFallback(converter, true) for many, many years
for our ICU-based text decoding.  However, when using ICU to encode
non-UTF8 text through a URL, we need to not use the fallback.
This matches the behavior of Chrome and Firefox, and Chromium has a
comment saying this matches Netscape behavior.

This behavior is odd but already implemented and specified in
https://url.spec.whatwg.org/#string-percent-encode-after-encoding

Chromium implemented this by using a class for the URL encoding,
ICUCharsetConverter which does not call ucnv_setFallback, and a
separate class for text encoding, and TextCodecIcu, which does call
ucnv_setFallback.  I've already used an abstract interface for this
rare case, URLTextEncoding, in order to keep it down to one
implementation, so I keep that design and use ucnv_setFallback
to turn off fallback when using UnencodableHandling::URLEncodedEntities
for URL query encoding, then I use ucnv_setFallback to reset the state
of the encoder when I'm done with the operation.

Test: imported/w3c/web-platform-tests/url/resources/percent-encoding.window.html

* 
LayoutTests/imported/w3c/web-platform-tests/url/percent-encoding.window-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/url/resources/percent-encoding.json:
* Source/WebCore/PAL/pal/text/TextCodecICU.cpp:
(PAL::TextCodecICU::encode const):

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



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

Reply via email to