feat(libSceNKWebKit): implement WTF::URLParser::allValuesEqual and internalValuesConsistent #15867
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15867"
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 KernelPanicNT on 2026-11-04T20:29:15Z.
What
Implements two
libSceNKWebKitexports that calledNotImplemented_nid_no_patch:WTF::URLParser::allValuesEqual(URL const&, URL const&)(MlSHagwBWI4) andWTF::URLParser::internalValuesConsistent(URL const&)(jKPJKar5yGY). Both are static, returnbooland follow WebKit'sURLParser.cpp. They use the 40-byteWTF::URLmodel the tree already has:String m_stringat 0, then the bitfield word at 8, then the sevenunsignedoffsets.allValuesEqualcompares the two strings the wayString == Stringdoes: the sameStringImplor two null impls are equal, a null impl and an empty one are not, and otherwise length and code units are compared, so 8-bit and 16-bit copies of the same text are equal. Then it compares every field.m_isValid,m_protocolIsInHTTPFamily,m_cannotBeABaseURL,m_portLengthandm_schemeEndfill the 32-bit bitfield word exactly (1+1+1+3+26 bits), so comparing the whole word compares all five, whatever the bit order. The seven offsets are then compared one by one. TheURL_PARSER_LOGcall has no effect, becauseURL_PARSER_DEBUGGINGis 0.internalValuesConsistentchecks the orderschemeEnd <= userStart <= userEnd <= passwordEnd <= hostEnd, thenhostEnd + portLength <= pathAfterLastSlash <= pathEnd <= queryEnd <= length. The scheme end comes from bits 6-31 and the port length from bits 3-5, asURL::protocol,URL::pathandURL::isHierarchicalalready decode them. The sum is unsigned, so it wraps modulo 2^32 as in WebKit, where the 3-bit field becomesintand is then converted tounsigned. A null string has length 0.URLreference throwsstd::invalid_argumentthrough the sameCheckedhelper asequalIgnoringFragmentIdentifierand the otherURLexports. AStringImplwith a null character pointer and a nonzero length throws in the existingUnithelper. These are the cases where WebKit dereferences invalid memory.WTF::URLParser::maybeCanonicalizeSchemeis left out. The module export is_ZN3WTF9URLParser23maybeCanonicalizeSchemeERKNS_6StringE, which takesString const&. The cited WebKit revision declaresstd::optional<String> maybeCanonicalizeScheme(StringView)instead, so its body is not the source of this export and its return ABI is not established. It still throws.One new debt entry records that the two functions were not compared with a console module. The two NID rows leave the list of throwing inventory exports. The
7429 of the 8703sentence keeps its historical value, as the file header says inventory prose does.Source of the behaviour
No device measurement was made for this change. The behaviour is the cited WebKit source.
allValuesEqualandinternalValuesConsistent:URLParser.cpp#L2976-L3031. Declarations:URLParser.h#L56-L57. Disabled logging:URLParser.cpp#L36-L42.URL.h#L229-L247.WTFString.h#L324,WTFString.h#L104,StringImpl.cpp#L1393-L1396andStringCommon.h#L321-L338.maybeCanonicalizeSchemesignature at that revision:URLParser.h#L65.URLParser.cpprevision fromc124b4197109(January 2020) to3539f609da3d. The next change to the file,638ac8184b38, renamesm_cannotBeABaseURLtom_hasOpaquePath. TheURL.hmember block has the same text frome762431f808c(December 2019) to3539f609da3d, and it also changes next in638ac8184b38. At3539f609da3d,URL.h,URL.cppandURLParser.hare byte-identical to the WebKit text the existing NKWebKit debt entries cite as their pinned source.URLParser.cppdiffers from that text only by one line moved at L1211-L1212, outside the cited range, so the cited line numbers are the same.Export.cpp#L20235-L20245,InventoryExports.hpp#L2031-L2033, and names and NIDs atlibSceNKWebKit.md#L1975-L1977.maybeCanonicalizeSchemestays atExport.cpp#L12323.WtfStringAbi.hpp#L23-L44,WtfString.cpp#L880-L884(port length),#L975-L978(scheme end), and the helpersChecked,ViewandEqualImplsat#L208-L220and#L308-L311. The null-reference throw followsequalIgnoringFragmentIdentifier.Open PRs: none implement these exports. #14303 (
protocolHostAndPortAreEqual) adds code at the same place inWtfString.cpp. #13992 changes the lines next to these stubs inExport.cppandInventoryExports.hpp. #14858 adds tests at the same place intests/Wtf.cpp, and #14918, #14919 and #14920 change its includes. Each of these conflicts is textual only.tools/pr_overlap.pyalso lists #13486 under the same exports, but that PR only changes relinker files; its branch is behindmain.Tested
Linux (GitHub Codespace, GCC 14), on
main9ab6a281ea.nkwebkit_wtfpasses with the newTestURLParserChecks, and the change builds without warnings. The test checks:allValuesEqual:internalValuesConsistent:httpsURL with user, password, port, path, query and fragment, and for the all-zero URL.hostEnd + 4 = pathAfterLastSlashfalse andhostEnd + 5true.queryEndpast a null string is false.hostEnd = 0xFFFFFFFFwith port length 1 wraps to 0 and passes; with port length 2 it fails.StringImplwith a null character pointer throws when two such strings are compared, and is equal to itself.Negative control, two runs of the same test: with the
bitscomparison inallValuesEqualand the port length ininternalValuesConsistentremoved, the library builds andnkwebkit_wtfaborts on a failed check; withExport.cpp,InventoryExports.hpp,WtfExports.hppandWtfString.cppfrommain, the test no longer compiles (too many arguments to function), because the two exports are again argument-lessNotImplemented_nid_no_patchstubs.tools/progress.py: +2 implemented functions (libSceNKWebKit 1309/11248 -> 1311/11248).tools/check_conventions.pypasses.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)