feat(libSceNKWebKit): implement WebCore::SQLiteFileSystem::computeHashForFileName on PAL::CryptoDigest #21173

Closed
B-Howell wants to merge 3 commits from upstream-pr/21173 into main
B-Howell commented 2026-11-15 22:20:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by B-Howell on 2026-11-15T22:20:36Z.


What

Implements WebCore::SQLiteFileSystem::computeHashForFileName(const WTF::String&) (_ZN7WebCore16SQLiteFileSystem22computeHashForFileNameERKN3WTF6StringE). It follows SQLiteFileSystem.cpp#L148-L165: it takes the lenient UTF-8 of the name, runs SHA-256 over it and returns 64 uppercase hex characters. It reuses the merged PAL::CryptoDigest (#19330), WTF::String::utf8 and WTF::String::fromUTF8, so no SHA or UTF-8 code is duplicated. The pinned header takes a StringView, but the console export takes const String&. Both produce the same UTF-8 bytes. The stub and its legacy declaration are removed, and a typed declaration goes in SQLiteFileSystemExports.hpp. The new file keeps the upstream Google BSD notice and a Derived from line. The export was not in the inventory table, so this PR only adds a debt fragment (docs/dev/debt/changes/feat-nkwebkit-sqlite-filename-hash.md).

Tested

Linux (WSL Ubuntu 22.04, GCC 11.4, Release), at 4f6a45d9bb on main 54fb9c85fa. The later merge of main ff36fea157 changes no libSceNKWebKit or libSceLibreSsl source. The new nkwebkit_sqlitefilesystemhash test covers the empty, abc and null String cases, Latin-1 and 16-bit text, 3-byte and surrogate-pair UTF-8, lone high and low surrogates as 3-byte lenient UTF-8, and a result that is 8-bit, 64 characters and uppercase. It also checks that the digest object is allocated once and freed.

  • Red control (the new export throwing): nkwebkit_sqlitefilesystemhash ....Subprocess aborted, _ZN7WebCore16SQLiteFileSystem22computeHashForFileNameERKN3WTF6StringE not implemented.
  • Green: nkwebkit_sqlitefilesystemhash and nkwebkit_palcryptodigest passed 3/3 runs. ^public_headers: 65/65 passed.
  • tools/progress.py: libSceNKWebKit 3150 -> 3151 of 11261 (+1).

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:5327825429 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21173). Originally posted by [B-Howell](https://github.com/B-Howell) on 2026-11-15T22:20:36Z. --- ### What Implements `WebCore::SQLiteFileSystem::computeHashForFileName(const WTF::String&)` (`_ZN7WebCore16SQLiteFileSystem22computeHashForFileNameERKN3WTF6StringE`). It follows [SQLiteFileSystem.cpp#L148-L165](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/platform/sql/SQLiteFileSystem.cpp#L148-L165): it takes the lenient UTF-8 of the name, runs SHA-256 over it and returns 64 uppercase hex characters. It reuses the merged `PAL::CryptoDigest` (#19330), `WTF::String::utf8` and `WTF::String::fromUTF8`, so no SHA or UTF-8 code is duplicated. The pinned header takes a `StringView`, but the console export takes `const String&`. Both produce the same UTF-8 bytes. The stub and its legacy declaration are removed, and a typed declaration goes in `SQLiteFileSystemExports.hpp`. The new file keeps the upstream Google BSD notice and a `Derived from` line. The export was not in the inventory table, so this PR only adds a debt fragment (`docs/dev/debt/changes/feat-nkwebkit-sqlite-filename-hash.md`). ### Tested Linux (WSL Ubuntu 22.04, GCC 11.4, Release), at 4f6a45d9bba on main 54fb9c85fa0. The later merge of main ff36fea1572 changes no libSceNKWebKit or libSceLibreSsl source. The new `nkwebkit_sqlitefilesystemhash` test covers the empty, `abc` and null String cases, Latin-1 and 16-bit text, 3-byte and surrogate-pair UTF-8, lone high and low surrogates as 3-byte lenient UTF-8, and a result that is 8-bit, 64 characters and uppercase. It also checks that the digest object is allocated once and freed. - Red control (the new export throwing): `nkwebkit_sqlitefilesystemhash ....Subprocess aborted`, `_ZN7WebCore16SQLiteFileSystem22computeHashForFileNameERKN3WTF6StringE not implemented`. - Green: `nkwebkit_sqlitefilesystemhash` and `nkwebkit_palcryptodigest` passed 3/3 runs. `^public_headers`: 65/65 passed. - `tools/progress.py`: libSceNKWebKit 3150 -> 3151 of 11261 (+1). ### 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-15 23:22:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-15T23:22:05Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: nkwebkit_sqlitefilesystemhash_tests built cleanly.
  • CTest (nkwebkit_sqlitefilesystemhash):
    1/1 Test #4250: nkwebkit_sqlitefilesystemhash ....   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 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/SQLiteFileSystem.cpp:47-62 implements _ZN7WebCore16SQLiteFileSystem22computeHashForFileNameERKN3WTF6StringE using PAL::CryptoDigest::Algorithm::SHA_256, WTF::String::utf8 in lenient mode (0), and WTF::String::fromUTF8 for the 64-character uppercase hex output.
    • Checked pointer and buffer safety in core/libs/prx/libSceNKWebKit/src/SQLiteFileSystem.cpp:50-52: handles null/empty CString buffers safely by checking utf8FileName.buffer and passing nullptr with length 0 when empty.
    • Verified resource management and error handling in core/libs/prx/libSceNKWebKit/src/SQLiteFileSystem.cpp:48-53: checks cryptoDigest allocation and releases CString, digest buffer, and CryptoDigest via RAII destructors.
    • Checked LP64/LLP64 portability in core/libs/prx/libSceNKWebKit/src/SQLiteFileSystem.cpp:54-61 and core/libs/prx/libSceNKWebKit/tests/SQLiteFileSystemHash.cpp: no narrowing conversions or platform-specific type mismatches.
    • Verified core/libs/prx/libSceNKWebKit/tests/SQLiteFileSystemHash.cpp:101-137 covers empty, null, 8-bit Latin-1, 16-bit UTF-16, 3-byte UTF-8, surrogate pairs, lone high/low surrogates, output shape, and guest heap allocation cleanup.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5913466457 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21173#pullrequestreview-5913466457). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-15T23:22:05Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `b734406b75`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `nkwebkit_sqlitefilesystemhash_tests` built cleanly. - **CTest** (`nkwebkit_sqlitefilesystemhash`): ``` 1/1 Test #4250: nkwebkit_sqlitefilesystemhash .... 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` 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/SQLiteFileSystem.cpp:47-62 implements _ZN7WebCore16SQLiteFileSystem22computeHashForFileNameERKN3WTF6StringE using PAL::CryptoDigest::Algorithm::SHA_256, WTF::String::utf8 in lenient mode (0), and WTF::String::fromUTF8 for the 64-character uppercase hex output. - Checked pointer and buffer safety in core/libs/prx/libSceNKWebKit/src/SQLiteFileSystem.cpp:50-52: handles null/empty CString buffers safely by checking utf8FileName.buffer and passing nullptr with length 0 when empty. - Verified resource management and error handling in core/libs/prx/libSceNKWebKit/src/SQLiteFileSystem.cpp:48-53: checks cryptoDigest allocation and releases CString, digest buffer, and CryptoDigest via RAII destructors. - Checked LP64/LLP64 portability in core/libs/prx/libSceNKWebKit/src/SQLiteFileSystem.cpp:54-61 and core/libs/prx/libSceNKWebKit/tests/SQLiteFileSystemHash.cpp: no narrowing conversions or platform-specific type mismatches. - Verified core/libs/prx/libSceNKWebKit/tests/SQLiteFileSystemHash.cpp:101-137 covers empty, null, 8-bit Latin-1, 16-bit UTF-16, 3-byte UTF-8, surrogate pairs, lone high/low surrogates, output shape, and guest heap allocation cleanup. Looks Good To Me

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