feat(libSceNKWebKit): implement WebCore::parseRange #18175

Merged
opxdelwin merged 4 commits from upstream-pr/18175 into main 2026-11-15 13:43:47 +00:00
opxdelwin commented 2026-11-10 18:20:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by opxdelwin on 2026-11-10T18:20:01Z.


What

Implements WebCore::parseRange(const String&, long long& rangeOffset, long long& rangeEnd, long long& rangeSuffixLength) (_ZN7WebCore10parseRangeERKN3WTF6StringERxS4_S4_) in libSceNKWebKit, removing its throwing stub. The declaration moves from LegacyExports.hpp to WebCoreParsersExports.hpp; null pointers throw std::invalid_argument.

The export is in the older 3.20 inventory only. The pinned PS5 11.x source has just the later parseRange(StringView, RangeAllowWhitespace, long long&, long long&), a different symbol, so this follows the mid-2019 upstream WebKit HTTPParsers.cpp with its stripWhiteSpace and toInt64Strict semantics. Source-only: the console binary is not checked, and the debt entry says so.

Behaviour kept as in that source, each covered by a test: a - suffix that is not an integer (bytes=-, bytes=-5,7) returns true with all outputs -1; there is no explicit comma check, a range list fails only because the last position is not an integer; the prefix test is (unit | 0x20), so U+001D matches =; whitespace is ASCII 0x09-0x0D and 0x20, and above 0xFF the Bidi White_Space_Neutral code points.

Tested

Ubuntu 24.04, GCC 13.3.0, Release, this branch merged into main at 3e63c9f68f, only nkwebkit_webcoreparsers_tests and its dependencies built:

  • ctest -R nkwebkit_webcoreparsers -V: passed, 0.02 s.
  • ctest -R public_headers: 65 of 65 passed.

Windows 11, MSYS2 UCRT64 GCC 16.2.0 (SEH), full build of nkwebkit_webcoreparsers_tests:

  • ctest -R nkwebkit_webcoreparsers -V: passed, 0.10 s. The new cases cover each accepted form, the case-insensitive prefix, whitespace, 63-bit overflow and LLONG_MIN, multi-range rejection, start > end, empty and null strings, null arguments, and 8-bit and 16-bit strings, with exhaustive 16-bit sweeps over the whitespace and prefix code units.
  • ctest -R public_headers: 65 of 65 passed.
  • python3 tools/check_conventions.py --base upstream/main: passed.
  • No title or homebrew was run. Configure needed -DCMAKE_SKIP_INSTALL_RULES=ON on this toolchain because 3rdparty/libxml2's install(EXPORT) fails with windows_seh_personalities not in any export set; that is unrelated to this change.

pr_overlap.py lists other NKWebKit PRs that edit Export.cpp and the debt file; none implements parseRange. #16853, #17540, #17695 and #17835 also touch WebCoreParsersExports.hpp or LegacyExports.hpp for different exports.

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:5246562876 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18175). Originally posted by [opxdelwin](https://github.com/opxdelwin) on 2026-11-10T18:20:01Z. --- ### What Implements `WebCore::parseRange(const String&, long long& rangeOffset, long long& rangeEnd, long long& rangeSuffixLength)` (`_ZN7WebCore10parseRangeERKN3WTF6StringERxS4_S4_`) in libSceNKWebKit, removing its throwing stub. The declaration moves from `LegacyExports.hpp` to `WebCoreParsersExports.hpp`; null pointers throw `std::invalid_argument`. The export is in the older 3.20 inventory only. The pinned PS5 11.x source has just the later `parseRange(StringView, RangeAllowWhitespace, long long&, long long&)`, a different symbol, so this follows the mid-2019 upstream WebKit [HTTPParsers.cpp](https://github.com/WebKit/WebKit/blob/ccda9bfb069d312ebdfbeb37a2151e0536968a1d/Source/WebCore/platform/network/HTTPParsers.cpp) with its `stripWhiteSpace` and `toInt64Strict` semantics. Source-only: the console binary is not checked, and the debt entry says so. Behaviour kept as in that source, each covered by a test: a `-` suffix that is not an integer (`bytes=-`, `bytes=-5,7`) returns true with all outputs -1; there is no explicit comma check, a range list fails only because the last position is not an integer; the prefix test is `(unit | 0x20)`, so U+001D matches `=`; whitespace is ASCII 0x09-0x0D and 0x20, and above 0xFF the Bidi `White_Space_Neutral` code points. ### 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. --> Ubuntu 24.04, GCC 13.3.0, Release, this branch merged into `main` at 3e63c9f68f, only `nkwebkit_webcoreparsers_tests` and its dependencies built: - `ctest -R nkwebkit_webcoreparsers -V`: passed, 0.02 s. - `ctest -R public_headers`: 65 of 65 passed. Windows 11, MSYS2 UCRT64 GCC 16.2.0 (SEH), full build of `nkwebkit_webcoreparsers_tests`: - `ctest -R nkwebkit_webcoreparsers -V`: passed, 0.10 s. The new cases cover each accepted form, the case-insensitive prefix, whitespace, 63-bit overflow and `LLONG_MIN`, multi-range rejection, `start > end`, empty and null strings, null arguments, and 8-bit and 16-bit strings, with exhaustive 16-bit sweeps over the whitespace and prefix code units. - `ctest -R public_headers`: 65 of 65 passed. - `python3 tools/check_conventions.py --base upstream/main`: passed. - No title or homebrew was run. Configure needed `-DCMAKE_SKIP_INSTALL_RULES=ON` on this toolchain because `3rdparty/libxml2`'s `install(EXPORT)` fails with `windows_seh_personalities` not in any export set; that is unrelated to this change. `pr_overlap.py` lists other NKWebKit PRs that edit `Export.cpp` and the debt file; none implements `parseRange`. #16853, #17540, #17695 and #17835 also touch `WebCoreParsersExports.hpp` or `LegacyExports.hpp` for different exports. ### 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
PrivacyOnion commented 2026-11-10 21:13:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-10T21:13:54Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: libSceNKWebKit, nkwebkit_webcoreparsers_tests built cleanly.
  • CTest (nkwebkit_webcoreparsers):
    1/1 Test #3632: nkwebkit_webcoreparsers ..........   Passed    0.09 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/include/WebCoreParsersExports.hpp, core/libs/prx/libSceNKWebKit/src/WebCoreParsers.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Pointer and bounds safety: Verified Checked() helper in core/libs/prx/libSceNKWebKit/src/WebCoreParsers.cpp:221-229 validates range, rangeOffset, rangeEnd, and rangeSuffixLength for nullptr and throws std::invalid_argument, while CodeUnits bounds-checks 8-bit and 16-bit text accesses.
    • Export symbol and ABI: Verified ZN7WebCore10parseRangeERKN3WTF6StringERxS4_S4 in core/libs/prx/libSceNKWebKit/include/WebCoreParsersExports.hpp:53 and src/WebCoreParsers.cpp:375 matches the expected SysV ABI signature and uses long long for LP64/LLP64 Itanium mangling (Rx).
    • Integer parsing and overflow: Verified ParseInt64Strict in core/libs/prx/libSceNKWebKit/src/WebCoreParsers.cpp:280-318 checks digit accumulation against integralMax / 10 to prevent 64-bit overflow, supports leading whitespace and signs, and handles LLONG_MIN via two's-complement arithmetic.
    • HTTP range parsing semantics: Verified ParseRange in core/libs/prx/libSceNKWebKit/src/WebCoreParsers.cpp:320-352 resets out parameters to -1, correctly parses exact byte ranges (0-499), prefix ranges (500-), suffix ranges (-500), rejects inverted ranges (5-4), and replicates upstream WebKit suffix leniency.
    • AGENTS.md compliance: Verified zero in-code comments were added in core/libs/prx/libSceNKWebKit/src/WebCoreParsers.cpp (only namespace closers), stub was cleanly removed from Export.cpp and LegacyExports.hpp, and known deviations are documented in docs/dev/debt/libSceNKWebKit.md.
    • Test coverage: Verified core/libs/prx/libSceNKWebKit/tests/WebCoreParsers.cpp:326-470 comprehensively exercises 8-bit and 16-bit strings, valid and invalid range forms, whitespace character sweeps, boundary conditions, and null argument rejection.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5849532293 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18175#pullrequestreview-5849532293). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-10T21:13:54Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `753ad44f7d`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `libSceNKWebKit`, `nkwebkit_webcoreparsers_tests` built cleanly. - **CTest** (`nkwebkit_webcoreparsers`): ``` 1/1 Test #3632: nkwebkit_webcoreparsers .......... Passed 0.09 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/include/WebCoreParsersExports.hpp`, `core/libs/prx/libSceNKWebKit/src/WebCoreParsers.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Pointer and bounds safety: Verified Checked() helper in core/libs/prx/libSceNKWebKit/src/WebCoreParsers.cpp:221-229 validates range, rangeOffset, rangeEnd, and rangeSuffixLength for nullptr and throws std::invalid_argument, while CodeUnits bounds-checks 8-bit and 16-bit text accesses. - Export symbol and ABI: Verified _ZN7WebCore10parseRangeERKN3WTF6StringERxS4_S4_ in core/libs/prx/libSceNKWebKit/include/WebCoreParsersExports.hpp:53 and src/WebCoreParsers.cpp:375 matches the expected SysV ABI signature and uses long long for LP64/LLP64 Itanium mangling (Rx). - Integer parsing and overflow: Verified ParseInt64Strict in core/libs/prx/libSceNKWebKit/src/WebCoreParsers.cpp:280-318 checks digit accumulation against integralMax / 10 to prevent 64-bit overflow, supports leading whitespace and signs, and handles LLONG_MIN via two's-complement arithmetic. - HTTP range parsing semantics: Verified ParseRange in core/libs/prx/libSceNKWebKit/src/WebCoreParsers.cpp:320-352 resets out parameters to -1, correctly parses exact byte ranges (0-499), prefix ranges (500-), suffix ranges (-500), rejects inverted ranges (5-4), and replicates upstream WebKit suffix leniency. - AGENTS.md compliance: Verified zero in-code comments were added in core/libs/prx/libSceNKWebKit/src/WebCoreParsers.cpp (only namespace closers), stub was cleanly removed from Export.cpp and LegacyExports.hpp, and known deviations are documented in docs/dev/debt/libSceNKWebKit.md. - Test coverage: Verified core/libs/prx/libSceNKWebKit/tests/WebCoreParsers.cpp:326-470 comprehensively exercises 8-bit and 16-bit strings, valid and invalid range forms, whitespace character sweeps, boundary conditions, and null argument rejection. - Note: the AI-assisted checkbox can stay. 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!18175
No description provided.