feat(libSceNKWebKit): implement WebCore::CookieUtil::defaultPathForURL #16642

Merged
AlexWhitehouse merged 1 commit from upstream-pr/16642 into main 2026-11-09 08:56:33 +00:00
AlexWhitehouse commented 2026-11-07 12:08:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlexWhitehouse on 2026-11-07T12:08:30Z.


What

Implements libSceNKWebKit WebCore::CookieUtil::defaultPathForURL(const WTF::URL&) (_ZN7WebCore10CookieUtil17defaultPathForURLERKN3WTF3URLE, NID itSSjy-a4Ig), which threw through NotImplemented_nid_no_patch. WebKit's curl cookie jar calls it when a cookie has no Path attribute (CookieJarDB.cpp).

Source: Source/WebCore/platform/network/curl/CookieUtil.cpp, lines 184–198, at the PS5 WebKit revision the NKWebKit debt file and earlier ports use (80f77e94). It is RFC 6265 §5.1.4:

String path = url.path().toString();
if (path.isEmpty() || !path.startsWith('/'))
    return "/"_s;
auto lastSlashPosition = path.reverseFind('/');
if (!lastSlashPosition)
    return "/"_s;
return path.left(lastSlashPosition);

src/CookieUtil.cpp starts with that file's notice, copied byte for byte.

Implementation:

  • Path: taken from the WTF::URL::path export already on main, which excludes the query and fragment and gives an empty view for an invalid URL. It is copied into a StringImpl of the same character width through the existing StringImpl::create exports, as toString() does.
  • Result: the prefix comes from the existing StringImpl::substring export. Each "/" result is a fresh 8-bit StringImpl that points at static literal bytes without copying them, as "/"_s builds one.
  • Returned string: returned by hidden pointer (sret) in the WTF::String layout WtfStringAbi.hpp already defines, with reference counts balanced.
  • Unchanged: no URL parsing or WtfString.cpp code is touched.

Debt: a new entry records that the console's URL/String layouts and return convention are unverified. Guest calls to StringImpl::destroy on the result still reach that export, which is a stub on main. The inventory count drops from 6401 to 6400.

Tested

  • New test tests/CookieUtil.cpp, registered by the NKWebKit tests glob. URL objects are built by hand in the layout main already defines, so the test doesn't depend on the open URL parser PRs (#14926–#14930, #15867).
    • Paths: a default-constructed URL, "", /, /file, /a/b, /a/b/, //x, a/b, an invalid URL, a long path, and non-ASCII 16-bit characters including a surrogate pair. Each runs with 8-bit and 16-bit URL strings, and each URL carries a query and fragment containing /.
    • Checks: the returned characters and width; a fresh StringImpl per call; the input's reference count unchanged; and balanced reference counts on the result, including after copying it.
  • Linux x86-64 (Ubuntu 26.04, GCC 15, Release), the NKWebKit group:
    • on main, the 39 existing tests pass and the new test fails with _ZN7WebCore10CookieUtil17defaultPathForURLERKN3WTF3URLE not implemented;
    • with this PR (61f6f17798), 40/40 pass.
  • Mutation check: keeping the final slash in the prefix (/a/b → /a/) fails the length assertion.
  • Windows 11 (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release): the NKWebKit group passes 40/40 at 61f6f17798, including nkwebkit_cookieutil, with no warnings in the new files.
  • python3 tools/check_conventions.py --base origin/main: all conventions checks passed.
  • python3 tools/pr_overlap.py --branch feat/libscenkwebkit-cookie-default-path: no open PR implements this export or works in CookieUtil.
    • It could not compare 77 PRs, all of which already conflict with main. Trial merges add no conflicts beyond the shared NKWebKit inventory count line.
    • Every open NKWebKit PR that changes that count line conflicts on it, and whichever merges second recounts.
    • A second NKWebKit PR of mine (parseCacheControlDirectives) will share that line too.

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:5201460962 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16642). Originally posted by [AlexWhitehouse](https://github.com/AlexWhitehouse) on 2026-11-07T12:08:30Z. --- ### What Implements libSceNKWebKit `WebCore::CookieUtil::defaultPathForURL(const WTF::URL&)` (`_ZN7WebCore10CookieUtil17defaultPathForURLERKN3WTF3URLE`, NID `itSSjy-a4Ig`), which threw through `NotImplemented_nid_no_patch`. WebKit's curl cookie jar calls it when a cookie has no `Path` attribute ([`CookieJarDB.cpp`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/platform/network/curl/CookieJarDB.cpp#L571-L572)). **Source:** [`Source/WebCore/platform/network/curl/CookieUtil.cpp`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/platform/network/curl/CookieUtil.cpp#L184-L198), lines 184–198, at the PS5 WebKit revision the NKWebKit debt file and earlier ports use (80f77e94). It is RFC 6265 §5.1.4: ```cpp String path = url.path().toString(); if (path.isEmpty() || !path.startsWith('/')) return "/"_s; auto lastSlashPosition = path.reverseFind('/'); if (!lastSlashPosition) return "/"_s; return path.left(lastSlashPosition); ``` `src/CookieUtil.cpp` starts with that file's notice, copied byte for byte. **Implementation:** - **Path:** taken from the `WTF::URL::path` export already on `main`, which excludes the query and fragment and gives an empty view for an invalid URL. It is copied into a `StringImpl` of the same character width through the existing `StringImpl::create` exports, as `toString()` does. - **Result:** the prefix comes from the existing `StringImpl::substring` export. Each `"/"` result is a fresh 8-bit `StringImpl` that points at static literal bytes without copying them, as `"/"_s` builds one. - **Returned string:** returned by hidden pointer (sret) in the `WTF::String` layout `WtfStringAbi.hpp` already defines, with reference counts balanced. - **Unchanged:** no URL parsing or `WtfString.cpp` code is touched. **Debt:** a new entry records that the console's URL/String layouts and return convention are unverified. Guest calls to `StringImpl::destroy` on the result still reach that export, which is a stub on `main`. The inventory count drops from 6401 to 6400. ### Tested - **New test `tests/CookieUtil.cpp`**, registered by the NKWebKit tests glob. URL objects are built by hand in the layout `main` already defines, so the test doesn't depend on the open URL parser PRs (#14926–#14930, #15867). - **Paths:** a default-constructed URL, `""`, `/`, `/file`, `/a/b`, `/a/b/`, `//x`, `a/b`, an invalid URL, a long path, and non-ASCII 16-bit characters including a surrogate pair. Each runs with 8-bit and 16-bit URL strings, and each URL carries a query and fragment containing `/`. - **Checks:** the returned characters and width; a fresh `StringImpl` per call; the input's reference count unchanged; and balanced reference counts on the result, including after copying it. - **Linux x86-64** (Ubuntu 26.04, GCC 15, Release), the NKWebKit group: - on `main`, the 39 existing tests pass and the new test fails with `_ZN7WebCore10CookieUtil17defaultPathForURLERKN3WTF3URLE not implemented`; - with this PR (61f6f17798), 40/40 pass. - **Mutation check:** keeping the final slash in the prefix (`/a/b` → `/a/`) fails the length assertion. - **Windows 11** (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release): the NKWebKit group passes 40/40 at 61f6f17798, including `nkwebkit_cookieutil`, with no warnings in the new files. - `python3 tools/check_conventions.py --base origin/main`: all conventions checks passed. - **`python3 tools/pr_overlap.py --branch feat/libscenkwebkit-cookie-default-path`:** no open PR implements this export or works in `CookieUtil`. - It could not compare 77 PRs, all of which already conflict with `main`. Trial merges add no conflicts beyond the shared NKWebKit inventory count line. - Every open NKWebKit PR that changes that count line conflicts on it, and whichever merges second recounts. - A second NKWebKit PR of mine (`parseCacheControlDirectives`) will share that line too. ### 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)
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!16642
No description provided.