feat(libSceNKWebKit): implement WTF::encodeWithURLEscapeSequences #16901

Merged
AlexWhitehouse merged 1 commit from upstream-pr/16901 into main 2026-11-11 15:11:52 +00:00
AlexWhitehouse commented 2026-11-07 21:11:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlexWhitehouse on 2026-11-07T21:11:19Z.


What

libSceNKWebKit WTF::encodeWithURLEscapeSequences(const WTF::String&) (_ZN3WTF28encodeWithURLEscapeSequencesERKNS_6StringE, NID 3DqiPW3mayI) threw not implemented. This PR ports it from the PS5 WebKit tree the other NKWebKit ports use, 80f77e94:

  • URL.cpp percentEncodeCharacters with URLParser::isInUserInfoEncodeSet;
  • the user-info class of URLParser.cpp's character table.

Behaviour:

  • No escaping needed: if no code unit is in the user-info encode set, the same StringImpl comes back with one more reference, as return input does upstream.
  • Escaping: otherwise the string is converted to UTF-8 with upstream's default lenient conversion. Every byte in the encode set becomes %XX with uppercase hex; the rest are copied.
  • Surrogates: as StringImpl::utf8 does at that revision, unpaired surrogates in the middle become U+FFFD, and a trailing unpaired high surrogate keeps its three-byte encoding. The conversion uses the existing StringView::utf8 export.
  • Allocation: the result is allocated through the existing StringImpl::create.
  • Nulls: a null String returns null. A non-empty string without character storage throws.

The new source starts with the notices of URL.cpp and URLParser.cpp. The stub and its inventory row are removed, the NKWebKit count drops from 6368 to 6367, and a debt entry records that the console ABI and behaviour are unverified.

Tested

  • New test: nkwebkit_wtfurlescape (core/libs/prx/libSceNKWebKit/tests/WtfUrlEscape.cpp) covers:
    • null and empty strings;
    • an unchanged string returning the same impl, with the reference count checked;
    • every ASCII character 0–127, NUL included;
    • Latin-1 8-bit strings;
    • UTF-16 with supplementary characters and unpaired surrogates in the middle and at the end;
    • for example, a b/@% becomes a%20b%2F%40%.
  • Linux x86-64 (Ubuntu 26.04, GCC 15, Release):
    • on main, the test fails with …encodeWithURLEscapeSequencesERKNS_6StringE not implemented;
    • with this PR, nkwebkit_wtfurlescape, nkwebkit_wtftext, nkwebkit_wtftext_allocation and public_headers pass.
  • Windows 11: (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release): nkwebkit_wtfurlescape, nkwebkit_wtftext and nkwebkit_wtftext_allocation pass at 43346398bc, with no compiler warnings in the changed files.
  • Mutation check: lowercase hex fails the test.
  • python3 tools/check_conventions.py --base origin/main: all checks passed.
  • python3 tools/pr_overlap.py: no open PR implements this export.
    • #15246, #16316, #16386 and my #16853 conflict only on the NKWebKit count line or debt insertion points. So do my #16642, #16643 and #16890 (simplifyWhiteSpace). Whichever merges second recounts.
    • I compared the changed lines of the other 68 NKWebKit PRs the tool listed. None changes this export or its NID. The URL parser series (#14926–#14930, #15867) implements other URL exports.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5205874738 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16901). Originally posted by [AlexWhitehouse](https://github.com/AlexWhitehouse) on 2026-11-07T21:11:19Z. --- ### What libSceNKWebKit `WTF::encodeWithURLEscapeSequences(const WTF::String&)` (`_ZN3WTF28encodeWithURLEscapeSequencesERKNS_6StringE`, NID `3DqiPW3mayI`) threw `not implemented`. This PR ports it from the PS5 WebKit tree the other NKWebKit ports use, 80f77e94: - [`URL.cpp`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/URL.cpp#L553) `percentEncodeCharacters` with `URLParser::isInUserInfoEncodeSet`; - the user-info class of [`URLParser.cpp`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/URLParser.cpp#L54)'s character table. Behaviour: - **No escaping needed:** if no code unit is in the user-info encode set, the same `StringImpl` comes back with one more reference, as `return input` does upstream. - **Escaping:** otherwise the string is converted to UTF-8 with upstream's default lenient conversion. Every byte in the encode set becomes `%XX` with uppercase hex; the rest are copied. - **Surrogates:** as [`StringImpl::utf8`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/text/StringImpl.cpp#L1547) does at that revision, unpaired surrogates in the middle become U+FFFD, and a trailing unpaired high surrogate keeps its three-byte encoding. The conversion uses the existing `StringView::utf8` export. - **Allocation:** the result is allocated through the existing `StringImpl::create`. - **Nulls:** a null String returns null. A non-empty string without character storage throws. The new source starts with the notices of `URL.cpp` and `URLParser.cpp`. The stub and its inventory row are removed, the NKWebKit count drops from 6368 to 6367, and a debt entry records that the console ABI and behaviour are unverified. ### Tested - **New test:** `nkwebkit_wtfurlescape` (`core/libs/prx/libSceNKWebKit/tests/WtfUrlEscape.cpp`) covers: - null and empty strings; - an unchanged string returning the same impl, with the reference count checked; - every ASCII character 0–127, NUL included; - Latin-1 8-bit strings; - UTF-16 with supplementary characters and unpaired surrogates in the middle and at the end; - for example, `a b/@%` becomes `a%20b%2F%40%`. - **Linux x86-64** (Ubuntu 26.04, GCC 15, Release): - on `main`, the test fails with `…encodeWithURLEscapeSequencesERKNS_6StringE not implemented`; - with this PR, `nkwebkit_wtfurlescape`, `nkwebkit_wtftext`, `nkwebkit_wtftext_allocation` and `public_headers` pass. - **Windows 11:** (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release): `nkwebkit_wtfurlescape`, `nkwebkit_wtftext` and `nkwebkit_wtftext_allocation` pass at 43346398bc, with no compiler warnings in the changed files. - **Mutation check:** lowercase hex fails the test. - `python3 tools/check_conventions.py --base origin/main`: all checks passed. - **`python3 tools/pr_overlap.py`:** no open PR implements this export. - #15246, #16316, #16386 and my #16853 conflict only on the NKWebKit count line or debt insertion points. So do my #16642, #16643 and #16890 (`simplifyWhiteSpace`). Whichever merges second recounts. - I compared the changed lines of the other 68 NKWebKit PRs the tool listed. None changes this export or its NID. The URL parser series (#14926–#14930, #15867) implements other URL exports. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
gabichuuuuu commented 2026-11-07 22:15:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T22:15:42Z.

Review: COMMENTED


Read 43346398bc against main.

ShouldEncode matches the UserInfo bit of URLParser.cpp's table at 80f77e94 character for character, plus everything above 0x7E, and the hex is uppercase as upperNibbleToASCIIHexDigit gives. Splitting the conversion into a mode-2 prefix and a mode-0 trailing lead reproduces upstream's lenient convertUTF16ToUTF8: interior and lone low surrogates become U+FFFD, and only a final unpaired lead keeps three bytes. That split is needed because main's ToUTF8 mode 0 keeps every lone surrogate. Null and unchanged strings return the same impl with one more reference, as return input does, and the {0xDBFF} empty-prefix case is safe because CopyCString returns a non-null buffer for zero bytes. I found no defect. The 6368 to 6367 count is right for current main; whichever of #16890 and #16853 merges after this has to recount.

Not run here; this is from reading the code.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5815249342 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16901#pullrequestreview-5815249342). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-07T22:15:42Z. **Review:** COMMENTED --- Read `43346398bc` against `main`. `ShouldEncode` matches the `UserInfo` bit of URLParser.cpp's table at `80f77e94` character for character, plus everything above 0x7E, and the hex is uppercase as `upperNibbleToASCIIHexDigit` gives. Splitting the conversion into a mode-2 prefix and a mode-0 trailing lead reproduces upstream's lenient `convertUTF16ToUTF8`: interior and lone low surrogates become U+FFFD, and only a final unpaired lead keeps three bytes. That split is needed because `main`'s `ToUTF8` mode 0 keeps every lone surrogate. Null and unchanged strings return the same impl with one more reference, as `return input` does, and the `{0xDBFF}` empty-prefix case is safe because `CopyCString` returns a non-null buffer for zero bytes. I found no defect. The 6368 to 6367 count is right for current `main`; whichever of #16890 and #16853 merges after this has to recount. Not run here; this is from reading the code. AI-assisted: yes.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!16901
No description provided.