feat(libSceNKWebKit): implement WKSecurityOrigin C API exports #15853

Closed
ashwin280802 wants to merge 28 commits from upstream-pr/15853 into main
ashwin280802 commented 2026-11-04 19:45:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ashwin280802 on 2026-11-04T19:45:10Z.


What

Implements WKSecurityOriginCopyDatabaseIdentifier, WKSecurityOriginCreateFromDatabaseIdentifier and WKSecurityOriginCreateFromString in libSceNKWebKit; they threw NotImplemented_nid_no_patch before.

  • Database identifier: protocol_ + encodeForFileName(host) + _port, and file__0 for file in any case (SecurityOriginData.cpp:100-146). Parsing it back does not decode, accepts trailing junk after the port, treats port 0 as no port, and returns null for no separators or an unparsable or overflowing port. The host is kept as written and default ports are dropped (SecurityOrigin.cpp:130-157).
  • CreateFromString: follows the URL Standard for http, https, ftp, ws, wss and file (trimming, slashes and backslashes, userinfo, ports, forbidden host characters, drive letters). Default ports (ftp 21, ws 80, http 80, wss 443, https 443) are dropped and an explicit port 0 is kept. Other schemes, schemes registered as no-access, invalid input and empty hosts give an opaque origin (empty protocol and host, null string, __0), as in SecurityOriginData.cpp:166-211 and WKSecurityOriginRef.cpp:38-70.
  • Deliberate divergence: there is no URL parser in the library, so inputs it would have to canonicalize throw std::runtime_error instead of returning a guess: IPv6 literals, percent-escapes, non-ASCII or xn-- hosts, IPv4 forms and blob:. Scheme handlers are not modelled. Both are in the debt file.
  • WKSecurityOriginCreate is unchanged and keeps its arguments as given, as the pinned API does.

Open PRs: tools/pr_overlap.py listed 79 open PRs it could not clear (this PR is one of them), because they edit the same shared files (Export.cpp, InventoryExports.hpp, the debt file). I searched open PR titles for SecurityOrigin; no other PR implements these exports.

Tested

Windows 11, MinGW-W64 g++ with Ninja, commit e0f14b1f31.

ctest --test-dir build-full -R ^(guest_)?nkwebkit_ -j4

11/37 Test #3324: nkwebkit_securityorigin ................   Passed    0.11 sec
37/37 Test #3300: nkwebkit_base ..........................   Passed    0.01 sec
100% tests passed out of 37

python3 tools/check_conventions.py --base origin/main

All conventions checks passed.

I changed 20 added conditions one at a time and the new test failed on all 20.

Not verified: the rest of the repository's tests, the Linux build and behaviour on a console. My local run of the wider suite flagged unrelated tests with base in their names as not run; I did not run those or measure them on main.

Not covered by a test: the registered no-access scheme stays registered until the process exits (there is no unregister export), so the test that registers http runs last.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5160533549 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15853). Originally posted by [ashwin280802](https://github.com/ashwin280802) on 2026-11-04T19:45:10Z. --- ### What Implements `WKSecurityOriginCopyDatabaseIdentifier`, `WKSecurityOriginCreateFromDatabaseIdentifier` and `WKSecurityOriginCreateFromString` in `libSceNKWebKit`; they threw `NotImplemented_nid_no_patch` before. - **Database identifier**: `protocol_` + `encodeForFileName(host)` + `_port`, and `file__0` for `file` in any case ([SecurityOriginData.cpp:100-146](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/page/SecurityOriginData.cpp#L100-L146)). Parsing it back does not decode, accepts trailing junk after the port, treats port 0 as no port, and returns null for no separators or an unparsable or overflowing port. The host is kept as written and default ports are dropped ([SecurityOrigin.cpp:130-157](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/page/SecurityOrigin.cpp#L130-L157)). - **CreateFromString**: follows the URL Standard for `http`, `https`, `ftp`, `ws`, `wss` and `file` (trimming, slashes and backslashes, userinfo, ports, forbidden host characters, drive letters). Default ports (`ftp` 21, `ws` 80, `http` 80, `wss` 443, `https` 443) are dropped and an explicit port 0 is kept. Other schemes, schemes registered as no-access, invalid input and empty hosts give an opaque origin (empty protocol and host, null string, `__0`), as in [SecurityOriginData.cpp:166-211](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/page/SecurityOriginData.cpp#L166-L211) and [WKSecurityOriginRef.cpp:38-70](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebKit/Shared/API/c/WKSecurityOriginRef.cpp#L38-L70). - **Deliberate divergence**: there is no URL parser in the library, so inputs it would have to canonicalize throw `std::runtime_error` instead of returning a guess: IPv6 literals, percent-escapes, non-ASCII or `xn--` hosts, IPv4 forms and `blob:`. Scheme handlers are not modelled. Both are in the debt file. - `WKSecurityOriginCreate` is unchanged and keeps its arguments as given, as the pinned API does. Open PRs: `tools/pr_overlap.py` listed 79 open PRs it could not clear (this PR is one of them), because they edit the same shared files (`Export.cpp`, `InventoryExports.hpp`, the debt file). I searched open PR titles for `SecurityOrigin`; no other PR implements these exports. ### Tested Windows 11, MinGW-W64 g++ with Ninja, commit e0f14b1f31. `ctest --test-dir build-full -R ^(guest_)?nkwebkit_ -j4` ``` 11/37 Test #3324: nkwebkit_securityorigin ................ Passed 0.11 sec 37/37 Test #3300: nkwebkit_base .......................... Passed 0.01 sec 100% tests passed out of 37 ``` `python3 tools/check_conventions.py --base origin/main` ``` All conventions checks passed. ``` I changed 20 added conditions one at a time and the new test failed on all 20. Not verified: the rest of the repository's tests, the Linux build and behaviour on a console. My local run of the wider suite flagged unrelated tests with `base` in their names as not run; I did not run those or measure them on `main`. Not covered by a test: the registered no-access scheme stays registered until the process exits (there is no unregister export), so the test that registers `http` runs last. ### 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
MarcZX10 commented 2026-11-18 04:45:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T04:45:43Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: fix invalid database identifiers being accepted as valid origins.

What I ran

  • Reviewed head 1c2104bb72b105cb2966d3c862c844849914d847 using the prepared diff and the pinned repository reader (repo_read.py).
  • No build or tests run; the Windows test results in the PR description are author-reported.

Results

Check Result Note
Changed code review failed Invalid identifier accepted
Build and tests not run Author-reported results only

Findings

Blocking

  • core/libs/prx/libSceNKWebKit/src/URL.cpp:563 accepts a database identifier whose port starts with digits but then contains junk. ParseUInt16AllowingTrailingJunk returns the numeric prefix, so inputs such as http_host_80junk produce a non-null origin instead of being rejected. This conflicts with the description’s stated behavior that unparsable ports return null, and the parser’s name indicates trailing junk is deliberately tolerated, but its return value does not distinguish that case from a valid port. Preserve the target behavior only if confirmed from the pinned source; otherwise reject the whole port suffix when parsing identifiers.

Non-blocking

None.

Not verified

  • Build, test suite, Linux behavior, console behavior, and ABI behavior were not independently verified.
  • The complete text of Export.cpp, InventoryExports.hpp, and docs/dev/debt/libSceNKWebKit.md was excluded from the review folder. Export.cpp and InventoryExports.hpp changes are shown in the diff; the debt-file change is shown in the diff. Other excluded full-file content was not read.
  • Files read: description.md, commits.md, manifest.json, diff.patch, MimeExports.hpp, WebKitValueExports.hpp, Mime.cpp, URL.cpp, and Types.hpp.

To get this to a good state

Reject identifier port suffixes with trailing non-whitespace junk, and add a regression case such as http_host_80junk expecting null. Re-run the focused NKWebKit tests on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5950933652 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15853#pullrequestreview-5950933652). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-18T04:45:43Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: fix invalid database identifiers being accepted as valid origins. ## What I ran - Reviewed head `1c2104bb72b105cb2966d3c862c844849914d847` using the prepared diff and the pinned repository reader (`repo_read.py`). - No build or tests run; the Windows test results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed code review | failed | Invalid identifier accepted | | Build and tests | not run | Author-reported results only | ## Findings ### Blocking - `core/libs/prx/libSceNKWebKit/src/URL.cpp:563` accepts a database identifier whose port starts with digits but then contains junk. `ParseUInt16AllowingTrailingJunk` returns the numeric prefix, so inputs such as `http_host_80junk` produce a non-null origin instead of being rejected. This conflicts with the description’s stated behavior that unparsable ports return null, and the parser’s name indicates trailing junk is deliberately tolerated, but its return value does not distinguish that case from a valid port. Preserve the target behavior only if confirmed from the pinned source; otherwise reject the whole port suffix when parsing identifiers. ### Non-blocking None. ## Not verified - Build, test suite, Linux behavior, console behavior, and ABI behavior were not independently verified. - The complete text of `Export.cpp`, `InventoryExports.hpp`, and `docs/dev/debt/libSceNKWebKit.md` was excluded from the review folder. `Export.cpp` and `InventoryExports.hpp` changes are shown in the diff; the debt-file change is shown in the diff. Other excluded full-file content was not read. - Files read: `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `MimeExports.hpp`, `WebKitValueExports.hpp`, `Mime.cpp`, `URL.cpp`, and `Types.hpp`. ## To get this to a good state Reject identifier port suffixes with trailing non-whitespace junk, and add a regression case such as `http_host_80junk` expecting null. Re-run the focused NKWebKit tests on the new head.
mihiii1337 commented 2026-11-23 15:23:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T15:23:18Z.

Review: CHANGES_REQUESTED


Reviewed exact head 1c2104bb72b105cb2966d3c862c844849914d847. First, one existing concern can be retired: the pinned database-identifier parser deliberately uses parseIntegerAllowingTrailingJunk<uint16_t>, so the submitted 80abc/8080abc expectations are correct. A URL such as https://host:443junk remains a separate invalid-URL case.

I found two remaining issues:

  • IsUnicodeCompatibleASCIIWhitespace omits vertical tab (U+000B), although pinned WTF includes it. http_host_\v8080tail must parse port 8080; the exact PR helper returned null. In a native A/B using the exact export bodies and repo object types, adding only c == u'\v' changed the fixture from exit 1 to exit 0 while overflow/no-digit cases remained rejected.
  • WKSecurityOriginCreateFromString uses a separate parser that rejects valid canonical IPv4, bracketed IPv6, and ASCII percent escapes in hosts (for example %65xample.test). Current main already has the shared WTF URL/SecurityOrigin pipeline for these cases. Please route this export through that implementation rather than maintaining a second parser. Unicode and xn-- hosts can remain explicitly limited until the common UTS46 work in #19562 lands; IPv4, IPv6 and ASCII host escapes are independent of that dependency.

MinGW GCC 15.2 accepted the exact URL.cpp and all three export signatures with the declared Windows guest ABI. The runtime fixture used host calling convention only for native exception unwinding and an inert no-access test double; no console path was run. Hosted Windows built and passed nkwebkit_base and nkwebkit_securityorigin on this head, but its cases do not cover the two findings above.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6024273541 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15853#pullrequestreview-6024273541). Originally posted by [mihiii1337](https://github.com/mihiii1337) on 2026-11-23T15:23:18Z. **Review:** CHANGES_REQUESTED --- Reviewed exact head `1c2104bb72b105cb2966d3c862c844849914d847`. First, one existing concern can be retired: the pinned database-identifier parser deliberately uses `parseIntegerAllowingTrailingJunk<uint16_t>`, so the submitted `80abc`/`8080abc` expectations are correct. A URL such as `https://host:443junk` remains a separate invalid-URL case. I found two remaining issues: - `IsUnicodeCompatibleASCIIWhitespace` omits vertical tab (`U+000B`), although pinned WTF includes it. `http_host_\v8080tail` must parse port 8080; the exact PR helper returned null. In a native A/B using the exact export bodies and repo object types, adding only `c == u'\v'` changed the fixture from exit 1 to exit 0 while overflow/no-digit cases remained rejected. - `WKSecurityOriginCreateFromString` uses a separate parser that rejects valid canonical IPv4, bracketed IPv6, and ASCII percent escapes in hosts (for example `%65xample.test`). Current `main` already has the shared WTF URL/SecurityOrigin pipeline for these cases. Please route this export through that implementation rather than maintaining a second parser. Unicode and `xn--` hosts can remain explicitly limited until the common UTS46 work in #19562 lands; IPv4, IPv6 and ASCII host escapes are independent of that dependency. MinGW GCC 15.2 accepted the exact `URL.cpp` and all three export signatures with the declared Windows guest ABI. The runtime fixture used host calling convention only for native exception unwinding and an inert no-access test double; no console path was run. Hosted Windows built and passed `nkwebkit_base` and `nkwebkit_securityorigin` on this head, but its cases do not cover the two findings above. AI-assisted: yes

Pull request closed

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!15853
No description provided.