feat(libSceNKWebKit): implement topPrivatelyControlledDomain and CustomHeaderFields::thirdPartyDomainsMatch #22997

Merged
opxdelwin merged 1 commit from upstream-pr/22997 into main 2026-11-18 16:55:53 +00:00
opxdelwin commented 2026-11-18 16:27:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by opxdelwin on 2026-11-18T16:27:36Z.


What

Implements two libSceNKWebKit exports from the 11.x inventory, ported from the pinned PS5 WebKit 11.x source (neonmodder123/PS5-WebKit-11.x@80f77e94c63e):

  • WebCore::topPrivatelyControlledDomain(WTF::String const&) (GxVDSv5dIws) returns the registrable domain of a host (www.example.co.uk gives example.co.uk). It follows PublicSuffixCurl.cpp and uses the libpsl integration already on main. A null or empty domain gives a null String. IP addresses and non-ASCII domains come back unchanged. localhost comes back lowercased. A public suffix gives a null String. Leading dots are skipped, and the rest goes to psl_registrable_domain.
  • WebCore::CustomHeaderFields::thirdPartyDomainsMatch(WTF::URL const&) const (-ivWQ60ptck) decides whether a page's custom header fields also apply to a third-party URL. It follows CustomHeaderFields.cpp and RegistrableDomain.h registrableDomainFromHost. An entry matches when it equals the URL's host, or when it is a *.domain pattern whose suffix the host ends with and which is longer than the host's registrable domain.

The stubs are removed from Export.cpp and InventoryExports.hpp, and the declarations move to PublicSuffixExports.hpp and CustomHeaderFieldsExports.hpp. The licence notices of all three upstream files are kept verbatim, each with a Derived from line. The debt fragment records that neither function has been compared with a console module, and that the results depend on the bundled libpsl 0.21.5 suffix list.

Tested

Unit tests only, no title. Targets libSceNKWebKit nkwebkit_publicsuffix_tests nkwebkit_customheaderfields_tests nkwebkit_forwarding_tests nkwebkit_symbolset_tests, run with ctest -R '^(nkwebkit_publicsuffix|nkwebkit_customheaderfields|nkwebkit_forwarding|nkwebkit_symbolset|public_headers.*)$'.

All on this commit (0cbe66a8f0, based on current main):

  • Linux (Docker), GCC: 69/69 passed.
  • Linux (Docker), Clang 18: 65/69 passed, including all four nkwebkit tests. The 4 failures are public_headers_compile_9/25/40/51, all -Winvalid-offsetof on Region in RegionExports.hpp, a known clang failure on main in a file this PR does not touch. GCC passes them.
  • Windows, MSYS2 UCRT64 GCC 16.2: 69/69 passed.
  • tools/check_conventions.py --base upstream/main and tools/debt_fold.py --check pass.

New tests cover: null and empty input, IP addresses, non-ASCII input, localhost, case folding, public suffixes, leading dots, multi-label suffixes, exact-host matches, *. patterns at and beyond the registrable-domain length, malformed patterns, empty hosts and null-argument throws.

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:5379886321 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22997). Originally posted by [opxdelwin](https://github.com/opxdelwin) on 2026-11-18T16:27:36Z. --- ### What Implements two libSceNKWebKit exports from the 11.x inventory, ported from the pinned PS5 WebKit 11.x source (`neonmodder123/PS5-WebKit-11.x@80f77e94c63e`): - `WebCore::topPrivatelyControlledDomain(WTF::String const&)` (`GxVDSv5dIws`) returns the registrable domain of a host (`www.example.co.uk` gives `example.co.uk`). It follows `PublicSuffixCurl.cpp` and uses the libpsl integration already on main. A null or empty domain gives a null String. IP addresses and non-ASCII domains come back unchanged. `localhost` comes back lowercased. A public suffix gives a null String. Leading dots are skipped, and the rest goes to `psl_registrable_domain`. - `WebCore::CustomHeaderFields::thirdPartyDomainsMatch(WTF::URL const&) const` (`-ivWQ60ptck`) decides whether a page's custom header fields also apply to a third-party URL. It follows `CustomHeaderFields.cpp` and `RegistrableDomain.h` `registrableDomainFromHost`. An entry matches when it equals the URL's host, or when it is a `*.domain` pattern whose suffix the host ends with and which is longer than the host's registrable domain. The stubs are removed from `Export.cpp` and `InventoryExports.hpp`, and the declarations move to `PublicSuffixExports.hpp` and `CustomHeaderFieldsExports.hpp`. The licence notices of all three upstream files are kept verbatim, each with a `Derived from` line. The debt fragment records that neither function has been compared with a console module, and that the results depend on the bundled libpsl 0.21.5 suffix list. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Unit tests only, no title. Targets `libSceNKWebKit nkwebkit_publicsuffix_tests nkwebkit_customheaderfields_tests nkwebkit_forwarding_tests nkwebkit_symbolset_tests`, run with `ctest -R '^(nkwebkit_publicsuffix|nkwebkit_customheaderfields|nkwebkit_forwarding|nkwebkit_symbolset|public_headers.*)$'`. All on this commit (`0cbe66a8f0`, based on current `main`): - Linux (Docker), GCC: 69/69 passed. - Linux (Docker), Clang 18: 65/69 passed, including all four nkwebkit tests. The 4 failures are `public_headers_compile_9/25/40/51`, all `-Winvalid-offsetof` on `Region` in `RegionExports.hpp`, a known clang failure on main in a file this PR does not touch. GCC passes them. - Windows, MSYS2 UCRT64 GCC 16.2: 69/69 passed. - `tools/check_conventions.py --base upstream/main` and `tools/debt_fold.py --check` pass. New tests cover: null and empty input, IP addresses, non-ASCII input, `localhost`, case folding, public suffixes, leading dots, multi-label suffixes, exact-host matches, `*.` patterns at and beyond the registrable-domain length, malformed patterns, empty hosts and null-argument throws. ### 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) 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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
PrivacyOnion commented 2026-11-18 16:31:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T16:31:21Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_customheaderfields_tests, nkwebkit_publicsuffix_tests built cleanly.
  • CTest (nkwebkit_customheaderfields, nkwebkit_publicsuffix):
    1/2 Test #4519: nkwebkit_customheaderfields ......   Passed    0.01 sec
    2/2 Test #4576: nkwebkit_publicsuffix ............   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/CustomHeaderFieldsExports.hpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/include/PublicSuffixExports.hpp, core/libs/prx/libSceNKWebKit/src/CustomHeaderFields.cpp, core/libs/prx/libSceNKWebKit/src/PublicSuffix.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified null pointer validation in _ZN7WebCore28topPrivatelyControlledDomainERKN3WTF6StringE and _ZNK7WebCore18CustomHeaderFields22thirdPartyDomainsMatchERKN3WTF3URLE, ensuring std::invalid_argument is thrown on null inputs.
    • Verified memory safety and bounds checking in CustomHeaderFields::thirdPartyDomainsMatch string comparisons, including StartsWithWildcard, DropFirstCharacter, EndsWith, and RegistrableDomainLength.
    • Verified libpsl integration in PublicSuffix.cpp (built-in suffix list query, ASCII validation, ASCII lowercasing, leading dot stripping, and correct Latin-1/UTF-8 string handling).
    • Verified compliance with AGENTS.md conventions, debt tracking via feat-libscenkwebkit-registrable-domain.md, and license/copyright attribution headers.
    • Verified comprehensive test coverage in tests/CustomHeaderFields.cpp and tests/PublicSuffix.cpp for ASCII/wide strings, IPv4/IPv6 addresses, wildcards, and edge cases.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5960834699 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22997#pullrequestreview-5960834699). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T16:31:21Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `0cbe66a8f0`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_customheaderfields_tests`, `nkwebkit_publicsuffix_tests` built cleanly. - **CTest** (`nkwebkit_customheaderfields`, `nkwebkit_publicsuffix`): ``` 1/2 Test #4519: nkwebkit_customheaderfields ...... Passed 0.01 sec 2/2 Test #4576: nkwebkit_publicsuffix ............ Passed 0.01 sec 100% tests passed, 0 tests failed out of 2 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/CustomHeaderFieldsExports.hpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/include/PublicSuffixExports.hpp`, `core/libs/prx/libSceNKWebKit/src/CustomHeaderFields.cpp`, `core/libs/prx/libSceNKWebKit/src/PublicSuffix.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified null pointer validation in _ZN7WebCore28topPrivatelyControlledDomainERKN3WTF6StringE and _ZNK7WebCore18CustomHeaderFields22thirdPartyDomainsMatchERKN3WTF3URLE, ensuring std::invalid_argument is thrown on null inputs. - Verified memory safety and bounds checking in CustomHeaderFields::thirdPartyDomainsMatch string comparisons, including StartsWithWildcard, DropFirstCharacter, EndsWith, and RegistrableDomainLength. - Verified libpsl integration in PublicSuffix.cpp (built-in suffix list query, ASCII validation, ASCII lowercasing, leading dot stripping, and correct Latin-1/UTF-8 string handling). - Verified compliance with AGENTS.md conventions, debt tracking via feat-libscenkwebkit-registrable-domain.md, and license/copyright attribution headers. - Verified comprehensive test coverage in tests/CustomHeaderFields.cpp and tests/PublicSuffix.cpp for ASCII/wide strings, IPv4/IPv6 addresses, wildcards, and edge cases. Looks Good To Me
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!22997
No description provided.