feat(libSceNKWebKit): implement WebCore::toString(Vector<ProxyServer>) and proxyServersForURL #24614

Merged
ToRaNek merged 1 commit from upstream-pr/24614 into main 2026-11-23 16:19:04 +00:00
ToRaNek commented 2026-11-20 21:01:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ToRaNek on 2026-11-20T21:01:04Z.


What

Implements two exports that were throwing stubs, both in the 3.20 inventory only:

  • WebCore::toString(const Vector<ProxyServer>&)
  • WebCore::proxyServersForURL(const URL&)

toString follows ProxyServer.cpp on the 24-byte ProxyServer of ProxyServer.h (type at 0, host at 8, port at 16):

  • an empty list gives DIRECT;
  • a direct entry gives DIRECT, and its host and port are not written;
  • an HTTP or HTTPS entry gives PROXY host:port, a SOCKS entry SOCKS host:port;
  • entries are joined with "; ".

Three details come from the source rather than from what one would guess:

  • A type outside the four enumerators matches no case, so the entry has no keyword and reads host:port.
  • A null or empty host writes nothing, and the port is a signed decimal, so the default port of -1 reads :-1.
  • The result is 8-bit unless a host forces 16 bits. StringBuilder keeps an 8-bit buffer when it is given a single 16-bit code unit that fits Latin-1 (StringBuilder.cpp L332-L335), so a one-character 16-bit host does not widen the string, while a longer one does even if every character is ASCII.

proxyServersForURL returns an empty vector through its hidden result pointer and does not read the URL, which is what ProxyServerCurl.cpp does; PlatformPlayStation.cmake builds the curl port. Whether the console build replaces that file is not known and is recorded in debt.

The five source files involved (ProxyServer.h, ProxyServer.cpp, ProxyServerCurl.cpp, StringBuilder.h, StringBuilder.cpp) are byte-identical at both ends of the window the 3.20 names allow (WebKit 34fe4d7c1658, 2020-06-13, and 9fd169d0da68, 2020-11-12).

Where StringBuilder would overflow String::MaxLength and assert, toString throws. A null vector, a non-empty vector with a null buffer and a null result pointer throw.

Tested

Windows 11, MinGW GCC 15.2.

  • nkwebkit_proxyserver passes: empty lists (null buffer, and a reserved buffer with size 0), each type, five out-of-range types, a four-entry list, null and empty hosts, ports -1, 0, INT_MAX and INT_MIN, Latin-1 in an 8-bit host, the three 16-bit cases above plus an empty 16-bit host, a mixed list that widens midway, host reference counts unchanged, and proxyServersForURL over a pre-filled result, with and without a URL.
  • Seven negative controls, each rebuilt and run, each makes the test fail: HTTPS writing its own keyword; ";" without the space; a direct entry going on to write host and port; widening on any 16-bit host; never widening; an empty list giving an empty string; the port written unsigned.
  • All 170 nkwebkit_* tests and patched_libraries pass on the branch.
  • python tools/check_conventions.py --base origin/main and python tools/debt_fold.py --check pass.

Not tested on a console.

Overlap (python tools/pr_overlap.py --branch feat/nkwebkit-proxy-server-to-string):

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5420208427 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24614). Originally posted by [ToRaNek](https://github.com/ToRaNek) on 2026-11-20T21:01:04Z. --- ### What Implements two exports that were throwing stubs, both in the 3.20 inventory only: - `WebCore::toString(const Vector<ProxyServer>&)` - `WebCore::proxyServersForURL(const URL&)` **`toString`** follows [ProxyServer.cpp](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WebCore/platform/network/ProxyServer.cpp#L33-L72) on the 24-byte `ProxyServer` of [ProxyServer.h](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WebCore/platform/network/ProxyServer.h#L63-L65) (type at 0, host at 8, port at 16): - an empty list gives `DIRECT`; - a direct entry gives `DIRECT`, and its host and port are not written; - an HTTP or HTTPS entry gives `PROXY host:port`, a SOCKS entry `SOCKS host:port`; - entries are joined with `"; "`. Three details come from the source rather than from what one would guess: - A type outside the four enumerators matches no `case`, so the entry has no keyword and reads ` host:port`. - A null or empty host writes nothing, and the port is a signed decimal, so the default port of -1 reads `:-1`. - The result is 8-bit unless a host forces 16 bits. `StringBuilder` keeps an 8-bit buffer when it is given a single 16-bit code unit that fits Latin-1 ([StringBuilder.cpp L332-L335](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WTF/wtf/text/StringBuilder.cpp#L332-L335)), so a one-character 16-bit host does not widen the string, while a longer one does even if every character is ASCII. **`proxyServersForURL`** returns an empty vector through its hidden result pointer and does not read the URL, which is what [ProxyServerCurl.cpp](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WebCore/platform/network/curl/ProxyServerCurl.cpp#L35-L39) does; `PlatformPlayStation.cmake` builds the curl port. Whether the console build replaces that file is not known and is recorded in debt. The five source files involved (`ProxyServer.h`, `ProxyServer.cpp`, `ProxyServerCurl.cpp`, `StringBuilder.h`, `StringBuilder.cpp`) are byte-identical at both ends of the window the 3.20 names allow (WebKit `34fe4d7c1658`, 2020-06-13, and `9fd169d0da68`, 2020-11-12). Where `StringBuilder` would overflow `String::MaxLength` and assert, `toString` throws. A null vector, a non-empty vector with a null buffer and a null result pointer throw. ### Tested Windows 11, MinGW GCC 15.2. - `nkwebkit_proxyserver` passes: empty lists (null buffer, and a reserved buffer with size 0), each type, five out-of-range types, a four-entry list, null and empty hosts, ports -1, 0, `INT_MAX` and `INT_MIN`, Latin-1 in an 8-bit host, the three 16-bit cases above plus an empty 16-bit host, a mixed list that widens midway, host reference counts unchanged, and `proxyServersForURL` over a pre-filled result, with and without a URL. - Seven negative controls, each rebuilt and run, each makes the test fail: HTTPS writing its own keyword; `";"` without the space; a direct entry going on to write host and port; widening on any 16-bit host; never widening; an empty list giving an empty string; the port written unsigned. - All 170 `nkwebkit_*` tests and `patched_libraries` pass on the branch. - `python tools/check_conventions.py --base origin/main` and `python tools/debt_fold.py --check` pass. Not tested on a console. **Overlap** (`python tools/pr_overlap.py --branch feat/nkwebkit-proxy-server-to-string`): - No open PR implements these two functions. #24322, a refactor that splits the large libraries into smaller ones, moves the two stubs without implementing them. - The tool could not compare 20 open PRs that already conflict with `main` and share `Export.cpp`, `LegacyExports.hpp` or `libSceNKWebKit.hpp` (#13515, #14138, #14164, #14259, #16510, #17550, #17569, #17771, #17793, #17805, #17912, #17917, #17933, #22678, #22684, #22689, #22937, #23847, #24154, #24172). I searched each of their diffs for the two export names and for `ProxyServer`: none mentions them. ### Checklist - [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) and the licence notice of code adapted from upstream (see AGENTS.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
PrivacyOnion commented 2026-11-20 22:12:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T22:12:46Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against a1d0be25b0:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_proxyserver_tests built cleanly.
  • CTest (nkwebkit_proxyserver):
    1/1 Test #4785: nkwebkit_proxyserver .............   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libSceNKWebKit/src/ProxyServer.cpp, core/libs/prx/libSceNKWebKit/src/ProxyServerCurl.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified core/libs/prx/libSceNKWebKit/src/ProxyServer.cpp: null checks on proxyServers and proxyServers->buffer (when size > 0), integer overflow guards against MaxStringLength, port signed integer formatting, and 8-bit vs 16-bit Latin-1 widening logic matching WebKit Source/WebCore/platform/network/ProxyServer.cpp.
    • Verified core/libs/prx/libSceNKWebKit/src/ProxyServerCurl.cpp: null checks on result out-pointer returning early invalid_argument exception and zeroing out buffer/capacity/size according to WebKit curl port behavior.
    • Verified core/libs/prx/libSceNKWebKit/include/ProxyServerExports.hpp: exact struct layouts, 64-bit alignment and static_asserts for ProxyServer (24 bytes) and ProxyServerVector (16 bytes).
    • Verified docs/dev/debt/changes/feat-nkwebkit-proxy-server-to-string.md: valid fragment formatting, proper classification under Functional, and exact upstream commit references.
    • Verified AGENTS.md compliance: no unauthorized comments added, exports properly declared, no forbidden dependencies or special-casing, conventions and negative control tests passing.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6000078019 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24614#pullrequestreview-6000078019). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T22:12:46Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `a1d0be25b0`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_proxyserver_tests` built cleanly. - **CTest** (`nkwebkit_proxyserver`): ``` 1/1 Test #4785: nkwebkit_proxyserver ............. Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp`, `core/libs/prx/libSceNKWebKit/src/ProxyServer.cpp`, `core/libs/prx/libSceNKWebKit/src/ProxyServerCurl.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified core/libs/prx/libSceNKWebKit/src/ProxyServer.cpp: null checks on proxyServers and proxyServers->buffer (when size > 0), integer overflow guards against MaxStringLength, port signed integer formatting, and 8-bit vs 16-bit Latin-1 widening logic matching WebKit Source/WebCore/platform/network/ProxyServer.cpp. - Verified core/libs/prx/libSceNKWebKit/src/ProxyServerCurl.cpp: null checks on result out-pointer returning early invalid_argument exception and zeroing out buffer/capacity/size according to WebKit curl port behavior. - Verified core/libs/prx/libSceNKWebKit/include/ProxyServerExports.hpp: exact struct layouts, 64-bit alignment and static_asserts for ProxyServer (24 bytes) and ProxyServerVector (16 bytes). - Verified docs/dev/debt/changes/feat-nkwebkit-proxy-server-to-string.md: valid fragment formatting, proper classification under Functional, and exact upstream commit references. - Verified AGENTS.md compliance: no unauthorized comments added, exports properly declared, no forbidden dependencies or special-casing, conventions and negative control tests passing. Looks Good To Me
MarcZX10 commented 2026-11-20 22:17:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T22:17:16Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the behavior is consistent with the described WebKit implementation, with console behavior still unverified.

What I ran

Reviewed head a1d0be25b0cfe8f09567ffa1c5e7fbfe14de3cb8 against the prepared diff. No build or tests were run. I read description.md, commits.md, manifest.json, diff.patch, and the full text of every included changed file except LegacyExports.hpp, whose changed lines are empty. I also read the changed portions of Export.cpp, the include site in libSceNKWebKit.hpp, and the StringView definition and ViewOf implementation in WtfStringAbi.hpp and WtfString.cpp. files.json was not available in the review folder; the manifest lists Export.cpp as excluded because it is too large.

Results

Check Result Note
Diff and changed code review passed Included changed files read
Build and tests not run Reported results were not independently verified
Console behavior not run Author records this as untested

Findings

Blocking

None.

Non-blocking

  • proxyServersForURL follows the curl-port behavior described in the change, but whether the console build uses this implementation remains uncertain. The change records that limitation as technical debt (core/libs/prx/libSceNKWebKit/src/ProxyServerCurl.cpp:33).

Not verified

The author reports Windows 11/MinGW tests and repository checks passing; I did not run them. I did not read the full 2,132-line LegacyExports.hpp because its changed lines are empty, or the excluded full Export.cpp; I inspected only the relevant Export.cpp ranges from the diff. I did not verify console implementation behavior or the author's upstream source comparison.

To get this to a good state

Nothing is required. Optional: compare proxyServersForURL with a console module and update the recorded technical debt if needed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6000123364 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24614#pullrequestreview-6000123364). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T22:17:16Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the behavior is consistent with the described WebKit implementation, with console behavior still unverified. ## What I ran Reviewed head `a1d0be25b0cfe8f09567ffa1c5e7fbfe14de3cb8` against the prepared diff. No build or tests were run. I read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, and the full text of every included changed file except `LegacyExports.hpp`, whose changed lines are empty. I also read the changed portions of `Export.cpp`, the include site in `libSceNKWebKit.hpp`, and the `StringView` definition and `ViewOf` implementation in `WtfStringAbi.hpp` and `WtfString.cpp`. `files.json` was not available in the review folder; the manifest lists `Export.cpp` as excluded because it is too large. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code review | passed | Included changed files read | | Build and tests | not run | Reported results were not independently verified | | Console behavior | not run | Author records this as untested | ## Findings ### Blocking None. ### Non-blocking - `proxyServersForURL` follows the curl-port behavior described in the change, but whether the console build uses this implementation remains uncertain. The change records that limitation as technical debt (`core/libs/prx/libSceNKWebKit/src/ProxyServerCurl.cpp:33`). ## Not verified The author reports Windows 11/MinGW tests and repository checks passing; I did not run them. I did not read the full 2,132-line `LegacyExports.hpp` because its changed lines are empty, or the excluded full `Export.cpp`; I inspected only the relevant `Export.cpp` ranges from the diff. I did not verify console implementation behavior or the author's upstream source comparison. ## To get this to a good state Nothing is required. Optional: compare `proxyServersForURL` with a console module and update the recorded technical debt if needed.
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!24614
No description provided.