Repository navigation
XPath: Do not accept whitespace characters other than #x20, #x9, #xD, and #xA & fix normalize-space() - #13080
Conversation
|
EWS run on previous version of this PR (hash f03c2c1) Details |
f03c2c1 to
8493b89
Compare
|
EWS run on previous version of this PR (hash 8493b89) Details |
There was a problem hiding this comment.
XPath code seems like the wrong place fro this generic function. I know that Anne and Darin have been discussing related cleanup recently, not sure how closely that's related.
There was a problem hiding this comment.
@annevk do you have a suggestion for a better location for this function?
There was a problem hiding this comment.
ASCIICType.h is a good location I think, following the recent move of isHTMLSpace (plus renaming) there, but then the name should be either isHTTPWhitespace or isASCIIWhitespaceMinusFormFeed/isASCIIWhitespaceMinusFF. We'll primarily use it for HTTP, MIME types, and such, but apparently also for some XML-related features that are not covered by libxml.
There was a problem hiding this comment.
Will wait for @annevk's response and will work accordingly.
There was a problem hiding this comment.
I think isASCIIWhitespaceMinusFormFeed is clearer name to me.
There was a problem hiding this comment.
@aproskuryakov & @cdumez - I am able to do this in local build but my PR Git setup is bad and if I rebased then it will mess-up. I am happy to do follow-up to fix address this. My local branch is outdated and don't have @annevk's PR, so it will lead to merge conflict, if I do and rebasing tends to also mess-up this commit. Or I can close this PR and do new with all changes in one go.
There was a problem hiding this comment.
Only issue is that @annevk has few open PRs, so I can do once all of them are merged and remove 'XMLSpace' from these functions and add them to 'ASCIICType.h' as suggested later.
8493b89 to
6946f67
Compare
|
EWS run on current version of this PR (hash 6946f67) Details |
… and #xA & fix normalize-space() https://bugs.webkit.org/show_bug.cgi?id=255841 Reviewed by Chris Dumez. This patch aligns WebKit with Blink / Chromium and Gecko / Firefox. Merge: https://chromium.googlesource.com/chromium/src.git/+/01fd8522eaf35abdfa468f79333b350df96e1b62 & https://chromium.googlesource.com/chromium/src.git/+/66c3b1b0ce745473f6478e1fa042d71f00ee9d47 This patch aligns WebKit with web-spec [1] & [2] and also fixes XML white spaces handling; #x20, #x9, #xD, and #xA. We incorrectly handled other white spaces such as U+3000. [1] https://www.w3.org/TR/1999/REC-xpath-19991116/#function-normalize-space [2] https://www.w3.org/TR/1999/REC-xpath-19991116/#NT-ExprWhitespace * Source/WebCore/xml/XPathFunctions.cpp: (FunNormalizeSpace::evaluate): * Source/WebCore/xml/XPathUtil.cpp: (isXMLSpace): Introduce new bool function * Source/WebCore/xml/XPathUtil.h: new bool function definition * Source/WebCore/xml/XPathParser.cpp: (Parser::skipWS): Use new 'isXMLSpace' function * LayoutTests/imported/w3c/web-platform-tests/domxpath/lexical-structure-expected.txt: Rebaselined * LayoutTests/imported/w3c/web-platform-tests/domxpath/fn-normalize-space-expected.txt: Rebaselined Canonical link: https://commits.webkit.org/263311@main
6946f67 to
7e1bc9e
Compare
|
Committed 263311@main (7e1bc9e): https://commits.webkit.org/263311@main Reviewed commits have been landed. Closing PR #13080 and removing active labels. |
https://bugs.webkit.org/show_bug.cgi?id=255872 rdar://108738795 Reviewed by Darin Adler. It turns out that JSON, HTTP, and XML all use the same whitespace definition, so let's make them share it. Also correct an existing comment for that function as \v is not part of isASCIIWhitespace(), but \f is. Furthermore, remove the "optimization" from these whitespace functions per a comment from Chris Dumez at WebKit#13080 (comment): > Just verified out of curiosity and llvm does generate the same code > with -O2 (tried both arm64 and x86_64): > > isXMLSpace1(char): // @isXMLSpace1(char) > mov x8, WebKit#9728 // =0x2600 > and w9, w0, #0xff > movk x8, WebKit#1, lsl WebKit#32 > cmp w9, WebKit#33 > cset w9, lo > lsr x8, x8, x0 > and w0, w9, w8 > ret > isXMLSpace2(char): // @isXMLSpace2(char) > mov x8, WebKit#9728 // =0x2600 > and w9, w0, #0xff > movk x8, WebKit#1, lsl WebKit#32 > cmp w9, WebKit#33 > cset w9, lo > lsr x8, x8, x0 > and w0, w9, w8 > ret > > Ahmad-S792 Let's simplify the code then. * Source/WTF/wtf/ASCIICType.h: (WTF::isASCIIWhitespace): (WTF::isJSONOrHTTPOrXMLWhitespace): (WTF::isJSONOrHTTPWhitespace): Deleted. * Source/WTF/wtf/JSONValues.cpp: (WTF::JSONImpl::Value::parseJSON): * Source/WTF/wtf/text/StringToIntegerConversion.h: * Source/WebCore/Modules/cache/DOMCache.cpp: (WebCore::hasResponseVaryStarHeaderValue): * Source/WebCore/Modules/cache/DOMCacheEngine.cpp: (WebCore::DOMCacheEngine::queryCacheMatch): * Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp: (WebCore::parseParameters): (WebCore::parseMIMEType): (WebCore::FetchBodyConsumer::packageFormData): * Source/WebCore/Modules/fetch/FetchHeaders.cpp: (WebCore::canWriteHeader): (WebCore::appendToHeaderMap): (WebCore::FetchHeaders::set): (WebCore::FetchHeaders::filterAndFill): * Source/WebCore/mathml/MathMLPresentationElement.cpp: (WebCore::MathMLPresentationElement::parseMathMLLength): * Source/WebCore/mathml/MathMLTokenElement.cpp: (WebCore::MathMLTokenElement::convertToSingleCodePoint): * Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp: (WebCore::ContentSecurityPolicyDirectiveList::parse): * Source/WebCore/platform/ReferrerPolicy.cpp: (WebCore::parseReferrerPolicy): * Source/WebCore/platform/network/DataURLDecoder.cpp: (WebCore::DataURLDecoder::DecodeTask::process): * Source/WebCore/platform/network/HTTPParsers.cpp: (WebCore::parseContentTypeOptionsHeader): (WebCore::parseClearSiteDataHeader): (WebCore::parseRange): (WebCore::parseCrossOriginResourcePolicyHeader): * Source/WebCore/platform/network/HTTPParsers.h: (WebCore::addToAccessControlAllowList): * Source/WebCore/platform/network/ParsedContentType.cpp: (WebCore::skipSpaces): (WebCore::parseToken): (WebCore::ParsedContentType::create): (WebCore::ParsedContentType::setContentType): * Source/WebCore/platform/network/ResourceResponseBase.cpp: (WebCore::ResourceResponseBase::containsInvalidHTTPHeaders const): * Source/WebCore/platform/network/TimingAllowOrigin.cpp: (WebCore::passesTimingAllowOriginCheck): * Source/WebCore/xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::setRequestHeader): * Source/WebCore/xml/XPathFunctions.cpp: (WebCore::XPath::FunNormalizeSpace::evaluate const): * Source/WebCore/xml/XPathParser.cpp: (WebCore::XPath::Parser::skipWS): * Source/WebCore/xml/XPathUtil.cpp: (WebCore::XPath::isXMLSpace): Deleted. * Source/WebCore/xml/XPathUtil.h: * Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp: (WebKit::CacheStorage::updateVaryInformation): * Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.cpp: (WebKit::WebSocketTask::WebSocketTask): * Source/WebKit/NetworkProcess/storage/CacheStorageRecord.h: (WebKit::CacheStorageRecordInformation::updateVaryHeaders): * Source/WebKit/WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::shouldSkipDecidePolicyForResponse const): Canonical link: https://commits.webkit.org/266253@main
7e1bc9e
6946f67
🛠 watch