feat(libSceNKWebKit): implement WTF::portAllowed #14345

Merged
voidlakhan merged 4 commits from upstream-pr/14345 into main 2026-11-05 18:24:10 +00:00
voidlakhan commented 2026-11-01 10:12:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by voidlakhan on 2026-11-01T10:12:20Z.


What

Implement WTF::portAllowed(const URL&) (mangled: _ZN3WTF11portAllowedERKNS_3URLE, NID: tRrU4kb6AtE) in libSceNKWebKit.

  • Replaced the throwing inventory stub in Export.cpp with a typed declaration in include/WtfExports.hpp and callable implementation in src/WtfString.cpp.
  • Retained the Apple Inc. and Research In Motion Limited copyright and 2-clause BSD license header at the top of src/WtfString.cpp for the ported WTF URL functions.
  • Implemented URLPort(const URL&) internal helper adapting URL::port() from pinned WebKit source neonmodder123/PS5-WebKit-11.x@80f77e9 and parseInteger<uint16_t> integer parsing semantics from Source/WTF/wtf/text/StringToIntegerConversion.h#L33-L104 with subtraction-based overflow bounds checking and whitespace skipping (isUnicodeCompatibleASCIIWhitespace: ' ', '\n', '\t', '\r', '\f').
  • Matched the authoritative 82-entry blockedPortList and exceptions from Source/WTF/wtf/URL.cpp#L952-L1051:
    • Returns true if no port is present or if the port is unparseable / out of range. In upstream WebKit, invalid ports or values above 65535 fail parseInteger and yield std::nullopt in URL::port(), which triggers if (!port) return true;. This behavior matches upstream engine semantics rather than an arbitrary fallback policy.
    • Returns true if the port is not in blockedPortList.
    • Upstream port list spans ports 1 (tcpmux) to 10080 (amanda); port 0 is allowed.
    • Allows ports 21 and 22 for FTP protocol (url.protocolIs("ftp")), including uppercase scheme.
    • Allows any port for file protocol (url.protocolIs("file")), including uppercase scheme.
  • Shared-helper coordination with PR #14303: PR #14303 implements _ZN3WTF27protocolHostAndPortAreEqualERKNS_3URLES2_ and this PR implements _ZN3WTF11portAllowedERKNS_3URLE. Both PRs share identical internal implementations of URLPort() and IsUnicodeCompatibleASCIIWhitespace(). Whichever PR merges second will rebase onto main and deduplicate into a single shared helper, preserving both PRs' exports and tests.
  • Added comprehensive unit tests in tests/Wtf.cpp covering allowed ports, blocked ports, FTP exceptions (including uppercase scheme), file exceptions (including uppercase scheme), unparseable ports (25x, 80junk), integer overflow (65536), whitespace variations (\t, \n, \r, \f), trailing junk, and 16-bit UTF-16 URLs.
  • Documented upstream provenance, implementation adaptation, and unverified console/Linux execution in docs/dev/debt/libSceNKWebKit.md.

Tested

  • Unit tests: ctest --test-dir build-full -R "^nkwebkit_wtf$" -V passed locally on Windows host (100% tests passed).
  • Conventions check: python tools/check_conventions.py --base upstream/main passed locally.
  • Diff hygiene: git diff --check upstream/main passed locally.
  • PR overlap check: python tools/pr_overlap.py --branch feat/nkwebkit-port-allowed verified no duplicate implementations outside companion PR #14303.
  • Testing limitations: Verified on Windows x86-64 with GCC/MinGW and synthetic URL memory structures. Linux runtime execution and physical PS5 console execution have not been verified.

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 (shares the URLPort helper with #14303; whichever merges second will rebase onto main and retain a single shared helper)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5106389651 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14345). Originally posted by [voidlakhan](https://github.com/voidlakhan) on 2026-11-01T10:12:20Z. --- ### What Implement `WTF::portAllowed(const URL&)` (mangled: `_ZN3WTF11portAllowedERKNS_3URLE`, NID: `tRrU4kb6AtE`) in `libSceNKWebKit`. - Replaced the throwing inventory stub in `Export.cpp` with a typed declaration in `include/WtfExports.hpp` and callable implementation in `src/WtfString.cpp`. - Retained the Apple Inc. and Research In Motion Limited copyright and 2-clause BSD license header at the top of `src/WtfString.cpp` for the ported WTF URL functions. - Implemented `URLPort(const URL&)` internal helper adapting `URL::port()` from pinned WebKit source [`neonmodder123/PS5-WebKit-11.x@80f77e9`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/URL.cpp#L158-L161) and `parseInteger<uint16_t>` integer parsing semantics from [`Source/WTF/wtf/text/StringToIntegerConversion.h#L33-L104`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/text/StringToIntegerConversion.h#L33-L104) with subtraction-based overflow bounds checking and whitespace skipping (`isUnicodeCompatibleASCIIWhitespace`: `' '`, `'\n'`, `'\t'`, `'\r'`, `'\f'`). - Matched the authoritative 82-entry `blockedPortList` and exceptions from [`Source/WTF/wtf/URL.cpp#L952-L1051`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/URL.cpp#L952-L1051): - Returns `true` if no port is present or if the port is unparseable / out of range. In upstream WebKit, invalid ports or values above 65535 fail `parseInteger` and yield `std::nullopt` in `URL::port()`, which triggers `if (!port) return true;`. This behavior matches upstream engine semantics rather than an arbitrary fallback policy. - Returns `true` if the port is not in `blockedPortList`. - Upstream port list spans ports 1 (`tcpmux`) to 10080 (`amanda`); port 0 is allowed. - Allows ports 21 and 22 for FTP protocol (`url.protocolIs("ftp")`), including uppercase scheme. - Allows any port for file protocol (`url.protocolIs("file")`), including uppercase scheme. - Shared-helper coordination with PR #14303: PR #14303 implements `_ZN3WTF27protocolHostAndPortAreEqualERKNS_3URLES2_` and this PR implements `_ZN3WTF11portAllowedERKNS_3URLE`. Both PRs share identical internal implementations of `URLPort()` and `IsUnicodeCompatibleASCIIWhitespace()`. Whichever PR merges second will rebase onto `main` and deduplicate into a single shared helper, preserving both PRs' exports and tests. - Added comprehensive unit tests in `tests/Wtf.cpp` covering allowed ports, blocked ports, FTP exceptions (including uppercase scheme), file exceptions (including uppercase scheme), unparseable ports (`25x`, `80junk`), integer overflow (`65536`), whitespace variations (`\t`, `\n`, `\r`, `\f`), trailing junk, and 16-bit UTF-16 URLs. - Documented upstream provenance, implementation adaptation, and unverified console/Linux execution in `docs/dev/debt/libSceNKWebKit.md`. ### Tested - Unit tests: `ctest --test-dir build-full -R "^nkwebkit_wtf$" -V` passed locally on Windows host (100% tests passed). - Conventions check: `python tools/check_conventions.py --base upstream/main` passed locally. - Diff hygiene: `git diff --check upstream/main` passed locally. - PR overlap check: `python tools/pr_overlap.py --branch feat/nkwebkit-port-allowed` verified no duplicate implementations outside companion PR #14303. - Testing limitations: Verified on Windows x86-64 with GCC/MinGW and synthetic `URL` memory structures. Linux runtime execution and physical PS5 console execution have not been verified. ### 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) - [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 (shares the `URLPort` helper with #14303; whichever merges second will rebase onto main and retain a single shared helper) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
CnRJay commented 2026-11-01 19:47:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:47:01Z.

Review: COMMENTED


Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (Unblocks: none is allowed), and it contained no code review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729914137 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14345#pullrequestreview-5729914137). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:47:01Z. **Review:** COMMENTED --- Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (`Unblocks: none` is allowed), and it contained no code review.
MarcZX10 commented 2026-11-02 06:07:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T06:07:27Z.

Review: COMMENTED


Reviewed — no blocking findings

WTF::portAllowed is now implemented: it parses the port from the URL, blocks the listed ports, and makes exceptions for ftp on 21 and 22 and for the file scheme. The stub is removed from Export.cpp and from the inventory, and the debt count drops by one. The hosted Windows run passed all 2594 cases, including nkwebkit_wtf, which holds the new test cases. The file header now carries WebKit's copyright and BSD notice, and that needs a provenance answer (below).

What I ran

  • Head ed545fd36f9a2070ccd68519cf7c7b062b68819c; base e0caf1360035286bd22b9f2a3030e97b880ffb28. 6 files, +248/-7: src/WtfString.cpp (+75: the license header, IsUnicodeCompatibleASCIIWhitespace, URLPort, portAllowed), tests/Wtf.cpp (+171), Export.cpp (stub removed), include/InventoryExports.hpp (one line removed), include/WtfExports.hpp (declaration added), and docs/dev/debt/libSceNKWebKit.md (+3/-1).
  • Read the production functions, the declaration, the debt diff, and the new test block in full (the port cases, the ftp and file exceptions, whitespace and junk around ports, wide-string URLs, and the null argument).
  • Read-only checks from the trusted main checkout: diff check, conventions and PR template, and the stack check all passed. ABI audit passed: 10333 symbols, no findings.
  • Hosted: the Windows job passed 2594 of 2594 cases; nkwebkit_wtf passed. One conventions run failed at 19:41 UTC and the latest run passed at 19:47 UTC, so the failure is superseded.
  • No MarcZX10 review at this head.

Results

Check Result Note
Diff check passed
Conventions and PR template passed conventions check from the main checkout; an earlier run failed and a later run passed
Mergeability and dependencies passed stack check passed
ABI audit (main-checkout tool) passed 10333 symbols, no findings
Port parsing (URLPort) passed by reading uses the port length bits and the host end; rejects non-digits, overflow above 65535, and junk after the digits
Blocked-port list and the ftp and file exceptions passed by reading the test pins the boundary ports and both exceptions
nkwebkit_wtf (hosted, Windows) passed the new test cases are in this test
Debt count and row passed by reading 7439 to 7438, with one row removed, matches one removed declaration
The list matches the upstream source not verified the list was not compared with WebKit here
Linux build and runtime tests not run Linux is skipped on pull requests
Negative controls not run no local build
Hosted CI passed windows passed (2594/2594); report, conventions and library-portability succeeded; linux, relinkers and write-watch skipped
Read-only check output

Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. ABI audit: passed (10333 symbols). Stack check: passed. Hosted: gh api repos/boykopovar/AnyPS5/commits/ed545fd36f9a2070ccd68519cf7c7b062b68819c/check-runs, and the Windows job log.

Negative control

Not run here. A negative control needs a build, and code from this head is not run here.

Findings

Blocking

None.

Non-blocking

  • Provenance: the PR adds WebKit's copyright and BSD notice (Apple Inc. and Research In Motion) to WtfString.cpp, which had none. The PR checklist says new third-party code is a submodule, and the debt entries for other WTF functions cite the pinned upstream source. Please say whether portAllowed and URLPort are adapted from WebKit. If they are, name the upstream file and revision in the debt entry. If they are not, drop the notice.
  • The function returns true when the port cannot be parsed (for example 80junk or a value above 65535). The tests pin that. It is a policy choice, and it is not checked against WebKit here.

Sources

Not verified

  • The blocked-port list against the upstream source.
  • The URL bit layout the tests build by hand, against the URL struct's definition in the repo (the tests pass on Windows, which shows the layout is consistent with the functions).
  • Linux behaviour.

To get this to a good state

  • Answer the provenance question above. Otherwise nothing blocking.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5732669245 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14345#pullrequestreview-5732669245). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T06:07:27Z. **Review:** COMMENTED --- # Reviewed — no blocking findings `WTF::portAllowed` is now implemented: it parses the port from the URL, blocks the listed ports, and makes exceptions for ftp on 21 and 22 and for the `file` scheme. The stub is removed from `Export.cpp` and from the inventory, and the debt count drops by one. The hosted Windows run passed all 2594 cases, including `nkwebkit_wtf`, which holds the new test cases. The file header now carries WebKit's copyright and BSD notice, and that needs a provenance answer (below). ## What I ran - Head `ed545fd36f9a2070ccd68519cf7c7b062b68819c`; base `e0caf1360035286bd22b9f2a3030e97b880ffb28`. 6 files, +248/-7: `src/WtfString.cpp` (+75: the license header, `IsUnicodeCompatibleASCIIWhitespace`, `URLPort`, `portAllowed`), `tests/Wtf.cpp` (+171), `Export.cpp` (stub removed), `include/InventoryExports.hpp` (one line removed), `include/WtfExports.hpp` (declaration added), and `docs/dev/debt/libSceNKWebKit.md` (+3/-1). - Read the production functions, the declaration, the debt diff, and the new test block in full (the port cases, the ftp and file exceptions, whitespace and junk around ports, wide-string URLs, and the null argument). - Read-only checks from the trusted main checkout: diff check, conventions and PR template, and the stack check all passed. ABI audit passed: 10333 symbols, no findings. - Hosted: the Windows job passed 2594 of 2594 cases; `nkwebkit_wtf` passed. One conventions run failed at 19:41 UTC and the latest run passed at 19:47 UTC, so the failure is superseded. - No MarcZX10 review at this head. ## Results | Check | Result | Note | | --- | --- | --- | | Diff check | passed | | | Conventions and PR template | passed | conventions check from the main checkout; an earlier run failed and a later run passed | | Mergeability and dependencies | passed | stack check passed | | ABI audit (main-checkout tool) | passed | 10333 symbols, no findings | | Port parsing (`URLPort`) | passed by reading | uses the port length bits and the host end; rejects non-digits, overflow above 65535, and junk after the digits | | Blocked-port list and the ftp and file exceptions | passed by reading | the test pins the boundary ports and both exceptions | | `nkwebkit_wtf` (hosted, Windows) | passed | the new test cases are in this test | | Debt count and row | passed by reading | 7439 to 7438, with one row removed, matches one removed declaration | | The list matches the upstream source | not verified | the list was not compared with WebKit here | | Linux build and runtime tests | not run | Linux is skipped on pull requests | | Negative controls | not run | no local build | | Hosted CI | passed | windows passed (2594/2594); report, conventions and library-portability succeeded; linux, relinkers and write-watch skipped | <details><summary>Read-only check output</summary> Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. ABI audit: passed (10333 symbols). Stack check: passed. Hosted: `gh api repos/boykopovar/AnyPS5/commits/ed545fd36f9a2070ccd68519cf7c7b062b68819c/check-runs`, and the Windows job log. </details> ## Negative control Not run here. A negative control needs a build, and code from this head is not run here. ## Findings **Blocking** None. **Non-blocking** - Provenance: the PR adds WebKit's copyright and BSD notice (Apple Inc. and Research In Motion) to `WtfString.cpp`, which had none. The PR checklist says new third-party code is a submodule, and the debt entries for other WTF functions cite the pinned upstream source. Please say whether `portAllowed` and `URLPort` are adapted from WebKit. If they are, name the upstream file and revision in the debt entry. If they are not, drop the notice. - The function returns `true` when the port cannot be parsed (for example `80junk` or a value above 65535). The tests pin that. It is a policy choice, and it is not checked against WebKit here. ## Sources - Production: https://github.com/boykopovar/AnyPS5/blob/ed545fd36f9a2070ccd68519cf7c7b062b68819c/core/libs/prx/libSceNKWebKit/src/WtfString.cpp - Test: https://github.com/boykopovar/AnyPS5/blob/ed545fd36f9a2070ccd68519cf7c7b062b68819c/core/libs/prx/libSceNKWebKit/tests/Wtf.cpp - Declaration: https://github.com/boykopovar/AnyPS5/blob/ed545fd36f9a2070ccd68519cf7c7b062b68819c/core/libs/prx/libSceNKWebKit/include/WtfExports.hpp - Debt entry: https://github.com/boykopovar/AnyPS5/blob/ed545fd36f9a2070ccd68519cf7c7b062b68819c/docs/dev/debt/libSceNKWebKit.md - Hosted log: Windows job for ed545fd36f (CTest 2594 of 2594) ## Not verified - The blocked-port list against the upstream source. - The URL bit layout the tests build by hand, against the URL struct's definition in the repo (the tests pass on Windows, which shows the layout is consistent with the functions). - Linux behaviour. ## To get this to a good state - Answer the provenance question above. Otherwise nothing blocking.
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!14345
No description provided.