feat(libSceNKWebKit): implement WTF::FileSystemImpl encodeForFileName, decodeFromFilename and lastComponentOfPathIgnoringTrailingSlash #14858
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14858"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by ashwin280802 on 2026-11-01T20:45:37Z.
What
Implements
WTF::FileSystemImpl::encodeForFileName(DM39YN-X56M),decodeFromFilename(dlR6Z857IFs) andlastComponentOfPathIgnoringTrailingSlash(3TsXk8jA39E) inlibSceNKWebKit, replacing threeNotImplemented_nid_no_patchstubs.Source: FileSystem.cpp L66-L210 at the revision the other NKWebKit entries pin. It is not measured on a console and the device's WebKit revision is unverified (debt entry updated).
encodeForFileNameescapes control characters, DEL, space, the characters" % * / : < > ?, the backslash and|, and unpaired surrogates, as%XXor%+XXXXabove 0xFF (uppercase hex). The result is 8-bit only if every output unit is at most 0xFF, as WTF'sStringBuilderproduces.decodeFromFilenamereturns a nullStringfor a truncated or non-hex escape.lastComponentOfPathIgnoringTrailingSlashuses/(the PlayStation port is notOS(WINDOWS)) and keeps WebKit's unsigned wraparound for"a/","/"and"a//".Deliberate divergences: a null
Stringreference throws where WebKit has undefined behaviour, and encoding past 2^31-1 units throwsstd::length_errorwhere WebKit hits a release assertion.No open PR implements these functions. #14303, #14345 and #14479 edit the same
WtfString.cppline (L918) as this change, #14479 and #14607 another (L1024), #14479 alsoWtfExports.hppandWtf.cpp, and #14387Wtf.cpp(L782-L784). #13515 and #14152 editExport.cpp(#14152 alsoInventoryExports.hpp) but the overlap tool could not compare them. Ten more edit only the NKWebKit debt file, as do all of the above, so a rebase conflict is possible.Tested
Windows 11 (MinGW-W64 GCC 15.2.0) and Linux in Docker (lavapipe, WSL2), at 3932685367. New
nkwebkit_wtfcases cover all 128 ASCII values, surrogates, 8-bit and 16-bit results, both hex cases, 15 malformed decode inputs, escapes cut off at the end of a shared substring, trailing-slash paths, non-shared empty strings and null references.ctest --test-dir build-full -R nkwebkit -V(all nine NKWebKit suites), and the same nine on both systems:python3 tools/check_conventions.py --base origin/mainpasses. I changed 57 conditions, statements and operators in the new code one at a time and the test failed on 53; the other four cannot be observed (two length guards need a string of several GiB, tworeservecalls only set capacity).Not covered by a test: the two
> 2^31-1length guards.Not verified: behaviour on a console; the rest of the test suite was not run, only the NKWebKit tests.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T03:50:15Z.
Review: APPROVED
Windows 11, WinLibs GCC 15.2.0 r7, Release. Head 3932685367 merged into upstream/main
93dbd0f82a:nkwebkit*suites andpublic_headers: 10/10 pass.:removed from the escape set inNeedsFileNameEscape,nkwebkit_wtffails in the all-ASCII loop (line 839).Checked against
FileSystem.cppat the pinned revision:needsEscapingtable (controls, space," % * / : < > ? \ |, DEL);%XXup to 0xFF and%+XXXXabove;Stringfor a truncated or non-hex escape;The two stated divergences (throwing on a null reference and past the length limit, where WebKit has UB or a release assert) are refusals rather than invented results.
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T18:48:43Z.
Review: APPROVED
@ashwin280802 approved again at
ede1bb0eb4.The rebase:
git range-diffagainst my approved3932685367changes none of this PR's own+/-lines. The only differences aremain's context lines aroundWtfExports.hpp. Because the earlier rebase (b86f430) broke the build without changing a PR line, I built it this time.What I ran: head
ede1bb0eb4, which already containsmain9ab6a281ea. Windows 11, WinLibs GCC 15.2.0, Release:nkwebkit_wtfandpublic_headerspass (2 of 2).'%'removed from the charactersencodeForFileNameescapes,nkwebkit_wtfaborts (0xc0000409). So the tests reach the new encoding.tools/check_conventions.py --base upstream/main --headon the head: all checks passed.pr_overlap.py --branchon the head:WtfString.cpplines, #14387 changestests/Wtf.cpplines 782 and 784, and about 20 NKWebKit PRs change the export count on line 36 ofdocs/dev/debt/libSceNKWebKit.md, #15125 among them. Whichever lands later will need a rebase there.int APS5_VABI _ZN3WTF14FileSystemImpl17encodeForFileNameERKNS_6StringE()in itsExport.cpp. So it doesn't implement them.