feat(libSceNKWebKit): implement WebCore::isValidContentType #16853
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16853"
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-07T18:24:31Z.
What
libSceNKWebKit
WebCore::isValidContentType(const WTF::String&, Mode)(_ZN7WebCore18isValidContentTypeERKN3WTF6StringENS_4ModeE, NIDewE3P6Jh1n4) threwnot implemented. This PR implements it from the PS5 WebKit tree the other NKWebKit ports use, 80f77e94:ParsedContentType.cppandParsedContentType.h. There, the export returns whetherParsedContentType::create(contentType, mode)succeeds.WTF::String, read as 8-bit or UTF-16 through the sameStringImplflags the other NKWebKit exports use.Modeis a 32-bit enum (Rfc2045 = 0,MimeSniff = 1), and the result is abool. NoParsedContentType, map or vector crosses the boundary.parseContentTypewith its quirks, rather than a standards-based validator:MimeSnifftrims HTTP whitespace first and checks type and subtype as RFC 7230 tokens.Rfc2045rejects CR/LF anywhere, stops tokens at the first non-token character (so trailing text after a valid subtype is accepted), and requires=and a value for every parameter.parseQuotedStringreads characters into achar, so it truncates them, and steps one past the closing quote. As a result,a="x";b=yis rejected inRfc2045mode whilea="x";;b=yis accepted.MimeSniffquoted-string collector and the empty-valuecontinuefollow the source.false, ascreatedoes for an empty string. A non-empty string with null character storage throwsstd::invalid_argument, where upstream would dereference null, matching the other NKWebKit string consumers.ParsedContentType.cpp's notice.WebCore::Modeand the export are declared inWebCoreParsersExports.hppbeside the other WebCore parser exports. The stub is removed fromExport.cpp,InventoryExports.hppand the inventory table, the NKWebKit count drops from 6000 to 5999 on currentmain, and a debt entry records that the console ABI and behaviour are unverified.Tested
nkwebkit_contenttypevalidationmakes 224 checks. It runs each of 53 strings in both modes, as both 8-bit and UTF-16WTF::Strings (212 checks), plus 4 UTF-16-only strings with characters above 0xFF, which cover thechartruncation (8), a nullStringin both modes (2), and a non-emptyStringwith null character storage in both modes, which must throwstd::invalid_argument(2). The strings cover:main, all 222 string calls throw_ZN7WebCore18isValidContentTypeERKN3WTF6StringENS_4ModeE not implemented(measured before the null-storage checks were added);779d7acdcd, all 224 checks pass.nkwebkit_contenttypevalidationpassed at e05ab3f35c, before the rebases and the header move, as did the neighbouringnkwebkit_httpheaderfield,nkwebkit_httpheadermap,nkwebkit_mimetyperegistry,nkwebkit_webcoreparsersandnkwebkit_wtftext(6/6), with no compiler warnings in the changed files. ThewindowsCI job builds the current head.Rfc2045andMimeSniffbranches fails 102 of the 222 string checks, includingtext/plain;in both widths. Throwing anot implementedstd::runtime_errorfor null storage instead ofstd::invalid_argumentfails both null-storage checks.python3 tools/check_conventions.py --base origin/main: all checks passed.python3 tools/pr_overlap.py --branch feat/libscenkwebkit-is-valid-content-type: no open PR implementsisValidContentTypeorParsedContentType.main, so the tool couldn't compare them. I read each one's diff by hand: none changes this export, its NID or the new files. Those that touchExport.cpp,InventoryExports.hppor the count line need only a recount when one merges, as do my #16642 and #16643.WebCore::ContentType, a different class.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 gabichuuuuu on 2026-11-07T22:15:45Z.
Review: COMMENTED
Read
6269107aaeagainstmain.I compared
ParsewithparseContentType,parseToken,parseQuotedStringandcollectHTTPQuotedStringat80f77e94and found no divergence. That includes thechartruncation in the RFC 2045 quoted string, the extra advance after the closing quote, and the empty-after-trim subtype, which upstream'ssubstringreturns as a non-null empty view. Theindex &&bound on the trailing-whitespace loop is equivalent, because the character before the token is always/or=.isHTTPSpaceand the RFC 7230 token set match HTTPParsers.h and RFC7230.cpp.Two optional notes:
ContentTypeValidation.cpp:150reports a non-empty string with null data asnot implemented, although the export is implemented and the input is invalid. The sibling ports (#16901, #16890) throwstd::invalid_argumentfor the same case.Modeenum and the export sit inWtfExports.hpp; the other WebCore parser exports and their enums live inWebCoreParsersExports.hppundernamespace WebCore.The body still says 6373 to 6372 and cites
e05ab3f35cfor the Windows run. The diff correctly does 6368 to 6367, and the source, test and header files are identical ate05ab3f35cand the head, so the run still applies.Not run here; this is from reading the code.
AI-assisted: yes.