feat(libSceNKWebKit): implement simple cross-origin request checks #18805
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18805"
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 AlexWhitehouse on 2026-11-12T10:40:57Z.
What
libSceNKWebKit
WebCore::isSimpleCrossOriginAccessRequest(const String&, const HTTPHeaderMap&)(_ZN7WebCore32isSimpleCrossOriginAccessRequestERKN3WTF6StringERKNS_13HTTPHeaderMapE, NIDeNFR5wiR41Y) threwnot implemented. This PR ports it from the PS5 WebKit tree the other NKWebKit ports use, 80f77e94:CrossOriginAccessControl.cpp: the request check;HTTPParsers.cpp:isCrossOriginSafeRequestHeaderand the per-header rules;ParsedContentType.cpp: the content-type parse.The new
src/CrossOriginRequest.cppstarts with those files' notices.Behaviour:
GET,HEADandPOSTqualify, compared case-sensitively as upstream.HTTPHeaderNamethat is safe with its value. Any uncommon (unnamed) header fails, as upstream.Accept: no CORS-unsafe bytes.Accept-LanguageandContent-Language: only alphanumerics and*,-.;=.Content-Type: no CORS-unsafe bytes, a valid MIME-sniff content type (through the existingisValidContentTypeexport), and a MIME type ofapplication/x-www-form-urlencoded,multipart/form-dataortext/plain, case-insensitively.Range: a singlebytes=start-[end]range with no spaces or tabs, asisSimpleRangeHeaderValuechecks. The range parser is private to this file, so the separateparseRangeexport (#18175) isn't touched.The stub and its inventory row are removed, and a debt entry records that the console's ABI is unverified.
Tested
nkwebkit_crossoriginrequest(core/libs/prx/libSceNKWebKit/tests/CrossOriginRequest.cpp) runs 1,383 checks covering:main, the test fails with…isSimpleCrossOriginAccessRequest… not implemented;nkwebkit_crossoriginrequest,nkwebkit_contenttypevalidation,nkwebkit_wtfandpublic_headerspass.nkwebkit_crossoriginrequest,nkwebkit_wtfandpublic_headerspass at e99b27fe72, with no compiler warnings in the changed files. The branch was then rebased onto currentmain, where an include line and the count line conflicted. I also removed a second copy of this PR's debt entry that the original commit had added by mistake. The focused tests pass again on Linux.python3 tools/check_conventions.py --base origin/main: all checks passed.python3 tools/pr_overlap.py: no open PR implements this export, its helpers or the new files. I compared every NKWebKit PR it couldn't compare automatically. #18175'sparseRangehunks aren't touched. Other NKWebKit PRs touch the same files but not this export.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 PrivacyOnion on 2026-11-12T10:49:33Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
ba2fadfff7:tools/check_conventions.pypassed;git diff --checkreported whitespace errors.nkwebkit_crossoriginrequest_testsbuilt cleanly.nkwebkit_crossoriginrequest):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.endis initialized to-1to represent an omitted end offset (such as inbytes=0-). WhenendTextis explicitly"-1"(as inbytes=0--1),ParseInteger(endText)succeeds and returns-1, leavingend = -1. Line 207 checks(end == -1 || end >= *start), which matches the sentinel and returnstrue, erroneously treating negative end offsets as open-ended ranges. Upstream WebCore (HTTPParsers.cpp:isSimpleRangeHeaderValue) checks!(*end < *start), rejecting negative offsets (-1 < 0). Furthermore, core/libs/prx/libSceNKWebKit/tests/CrossOriginRequest.cpp:97 asserts{HTTPHeaderName::Range, u"bytes=0--1", true}, codifying this bug in the unit test.Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T11:05:00Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
91883b268a:tools/check_conventions.pypassed;git diff --checkreported whitespace errors.nkwebkit_crossoriginrequest_testsbuilt cleanly.nkwebkit_crossoriginrequest):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T11:35:31Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
183e2bf853:tools/check_conventions.pypassed;git diff --checkreported whitespace errors.nkwebkit_crossoriginrequest_testsbuilt cleanly.nkwebkit_crossoriginrequest):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T12:50:11Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
09743a4cc2:tools/check_conventions.pypassed;git diff --checkreported whitespace errors.nkwebkit_crossoriginrequest_testsbuilt cleanly.nkwebkit_crossoriginrequest):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T14:44:37Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
2fc6bcc5b8:tools/check_conventions.pypassed;git diff --checkreported whitespace errors.nkwebkit_crossoriginrequest_testsbuilt cleanly.nkwebkit_crossoriginrequest):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-13T03:55:03Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
d89a635031:tools/check_conventions.pypassed;git diff --checkreported whitespace errors.nkwebkit_crossoriginrequest_testsbuilt cleanly.nkwebkit_crossoriginrequest):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-13T13:03:43Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
120914b08f:tools/check_conventions.pypassed;git diff --checkreported whitespace errors.nkwebkit_crossoriginrequest_testsbuilt cleanly.nkwebkit_crossoriginrequest):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-13T17:16:09Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
bda75ebb09:tools/check_conventions.pypassed;git diff --checkreported whitespace errors.nkwebkit_crossoriginrequest_testsbuilt cleanly.nkwebkit_crossoriginrequest):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-13T18:23:39Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
5410e58045:tools/check_conventions.pypassed;git diff --checkreported whitespace errors.nkwebkit_crossoriginrequest_testsbuilt cleanly.nkwebkit_crossoriginrequest):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass._ZN7WebCore32isSimpleCrossOriginAccessRequestERKN3WTF6StringERKNS_13HTTPHeaderMapEin core/libs/prx/libSceNKWebKit/src/CrossOriginRequest.cpp: method validation enforces exact case-sensitive matching for 'GET', 'HEAD', and 'POST', correctly returning false on empty, null, or alternative methods.IsSafeHeaderin core/libs/prx/libSceNKWebKit/src/CrossOriginRequest.cpp: strictly enforces the 128-code-unit length limit, checks CORS-unsafe bytes on 'Accept', permits only alphanumeric characters and allowed punctuation (*,-.;=) on 'Accept-Language' and 'Content-Language', and validates MIME type and sniffing rules on 'Content-Type'.IsSafeRangeandParseIntegerin core/libs/prx/libSceNKWebKit/src/CrossOriginRequest.cpp: correctly disallows spaces and tabs, handles 'bytes=' prefixing and HTTP space trimming, enforces single-range syntax, and performs exact overflow-checked 64-bit integer parsing againstLLONG_MAXandLLONG_MIN.CodeUnitsand map iteration: safely handles nullWTF::Stringpointers, validatesvalue.impl->datawhen length is non-zero, throwsstd::invalid_argumenton null buffer storage with non-zero size or out-of-rangeHTTPHeaderNameenum indices, and correctly supports both 8-bit and UTF-16 character encodings.Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-15T21:07:37Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
5410e58045:tools/check_conventions.pypassed;git diff --checkreported whitespace errors.nkwebkit_crossoriginrequest_testsbuilt cleanly.nkwebkit_crossoriginrequest):Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T10:58:12Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
b6656020c1:tools/check_conventions.pypassed;git diff --checkreported whitespace errors.nkwebkit_crossoriginrequest_testsbuilt cleanly.nkwebkit_crossoriginrequest):Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T19:40:32Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
b6656020c1:tools/check_conventions.pypassed.nkwebkit_crossoriginrequest_testsbuilt cleanly.nkwebkit_crossoriginrequest):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-17T21:58:37Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
8d8cba4b75:tools/check_conventions.pypassed.nkwebkit_crossoriginrequest_testsbuilt cleanly.nkwebkit_crossoriginrequest):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp,core/libs/prx/libSceNKWebKit/src/CrossOriginRequest.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me