Title: [219076] trunk
Revision
219076
Author
[email protected]
Date
2017-07-03 10:20:25 -0700 (Mon, 03 Jul 2017)

Log Message

REGRESSION(r215096) Queries of URLs with non-special schemes should not percent-encode single quotes
https://bugs.webkit.org/show_bug.cgi?id=174051

Reviewed by Tim Horton.

Source/WebCore:

In r215096 I added ' to the set of characters to be percent-encoded in queries,
but for interoperability and compatibility we need to do this only for special schemes, like http.

Covered by new API tests.

* platform/URLParser.cpp:
(WebCore::isC0Control):
(WebCore::shouldPercentEncodeQueryByte):
(WebCore::URLParser::utf8QueryEncode):
(WebCore::URLParser::encodeQuery):

Tools:

* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (219075 => 219076)


--- trunk/Source/WebCore/ChangeLog	2017-07-03 17:18:34 UTC (rev 219075)
+++ trunk/Source/WebCore/ChangeLog	2017-07-03 17:20:25 UTC (rev 219076)
@@ -1,3 +1,21 @@
+2017-07-03  Alex Christensen  <[email protected]>
+
+        REGRESSION(r215096) Queries of URLs with non-special schemes should not percent-encode single quotes
+        https://bugs.webkit.org/show_bug.cgi?id=174051
+
+        Reviewed by Tim Horton.
+
+        In r215096 I added ' to the set of characters to be percent-encoded in queries,
+        but for interoperability and compatibility we need to do this only for special schemes, like http.
+
+        Covered by new API tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::isC0Control):
+        (WebCore::shouldPercentEncodeQueryByte):
+        (WebCore::URLParser::utf8QueryEncode):
+        (WebCore::URLParser::encodeQuery):
+
 2017-07-03  Chris Fleizach  <[email protected]>
 
         AX: role="none" (or presentation) does not work on iframes

Modified: trunk/Source/WebCore/platform/URLParser.cpp (219075 => 219076)


--- trunk/Source/WebCore/platform/URLParser.cpp	2017-07-03 17:18:34 UTC (rev 219075)
+++ trunk/Source/WebCore/platform/URLParser.cpp	2017-07-03 17:20:25 UTC (rev 219076)
@@ -191,7 +191,7 @@
     0, // '$'
     ForbiddenHost, // '%'
     0, // '&'
-    QueryPercent, // '''
+    0, // '''
     0, // '('
     0, // ')'
     0, // '*'
@@ -420,7 +420,14 @@
 template<typename CharacterType> ALWAYS_INLINE static bool isSlashQuestionOrHash(CharacterType character) { return character <= '\\' && characterClassTable[character] & SlashQuestionOrHash; }
 template<typename CharacterType> ALWAYS_INLINE static bool isValidSchemeCharacter(CharacterType character) { return character <= 'z' && characterClassTable[character] & ValidScheme; }
 template<typename CharacterType> ALWAYS_INLINE static bool isForbiddenHostCodePoint(CharacterType character) { return character <= ']' && characterClassTable[character] & ForbiddenHost; }
-static bool shouldPercentEncodeQueryByte(uint8_t byte) { return characterClassTable[byte] & QueryPercent; }
+ALWAYS_INLINE static bool shouldPercentEncodeQueryByte(uint8_t byte, const bool& urlIsSpecial)
+{
+    if (characterClassTable[byte] & QueryPercent)
+        return true;
+    if (byte == '\'' && urlIsSpecial)
+        return true;
+    return false;
+}
 
 template<typename CharacterType, URLParser::ReportSyntaxViolation reportSyntaxViolation>
 ALWAYS_INLINE void URLParser::advance(CodePointIterator<CharacterType>& iterator, const CodePointIterator<CharacterType>& iteratorForSyntaxViolationPosition)
@@ -578,7 +585,7 @@
     ASSERT(!iterator.atEnd());
     UChar32 codePoint = *iterator;
     if (LIKELY(isASCII(codePoint))) {
-        if (UNLIKELY(shouldPercentEncodeQueryByte(codePoint))) {
+        if (UNLIKELY(shouldPercentEncodeQueryByte(codePoint, m_urlIsSpecial))) {
             syntaxViolation(iterator);
             percentEncodeByte(codePoint);
         } else
@@ -598,7 +605,7 @@
     U8_APPEND_UNSAFE(buffer, offset, codePoint);
     for (int32_t i = 0; i < offset; ++i) {
         auto byte = buffer[i];
-        if (shouldPercentEncodeQueryByte(byte))
+        if (shouldPercentEncodeQueryByte(byte, m_urlIsSpecial))
             percentEncodeByte(byte);
         else
             appendToASCIIBuffer(byte);
@@ -626,7 +633,7 @@
             syntaxViolation(iterator);
             break;
         }
-        if (UNLIKELY(shouldPercentEncodeQueryByte(byte))) {
+        if (UNLIKELY(shouldPercentEncodeQueryByte(byte, m_urlIsSpecial))) {
             syntaxViolation(iterator);
             break;
         }
@@ -639,7 +646,7 @@
     for (; i < length; ++i) {
         ASSERT(m_didSeeSyntaxViolation);
         uint8_t byte = data[i];
-        if (shouldPercentEncodeQueryByte(byte))
+        if (shouldPercentEncodeQueryByte(byte, m_urlIsSpecial))
             percentEncodeByte(byte);
         else
             appendToASCIIBuffer(byte);

Modified: trunk/Tools/ChangeLog (219075 => 219076)


--- trunk/Tools/ChangeLog	2017-07-03 17:18:34 UTC (rev 219075)
+++ trunk/Tools/ChangeLog	2017-07-03 17:20:25 UTC (rev 219076)
@@ -1,3 +1,13 @@
+2017-07-03  Alex Christensen  <[email protected]>
+
+        REGRESSION(r215096) Queries of URLs with non-special schemes should not percent-encode single quotes
+        https://bugs.webkit.org/show_bug.cgi?id=174051
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2017-07-03  Matt Lewis  <[email protected]>
 
         Unreviewed, rolling out r219024.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (219075 => 219076)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2017-07-03 17:18:34 UTC (rev 219075)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2017-07-03 17:20:25 UTC (rev 219076)
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright (C) 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -1298,7 +1298,8 @@
     checkURL(makeString("gopher://host/path?", withUmlauts, "#fragment"), "asdf://example.com/?doesntmatter", iso88591, {"gopher", "", "", "host", 0, "/path", "%DC%26%231072%3B%26%231105%3B", "fragment", "gopher://host/path?%DC%26%231072%3B%26%231105%3B#fragment"});
     checkURL(makeString("asdf://host/path?", withUmlauts, "#fragment"), "http://example.com/?doesntmatter", iso88591, {"asdf", "", "", "host", 0, "/path", "%C3%9C%D0%B0%D1%91", "fragment", "asdf://host/path?%C3%9C%D0%B0%D1%91#fragment"});
 
-    checkURL("http://host/?query=foo'bar", UTF8Encoding(), {"http", "", "", "host", 0, "/", "query=foo%27bar", "", "http://host/?query=foo%27bar"});
+    checkURL("http://host/pa'th?qu'ery#fr'agment", UTF8Encoding(), {"http", "", "", "host", 0, "/pa'th", "qu%27ery", "fr'agment", "http://host/pa'th?qu%27ery#fr'agment"});
+    checkURL("asdf://host/pa'th?qu'ery#fr'agment", UTF8Encoding(), {"asdf", "", "", "host", 0, "/pa'th", "qu'ery", "fr'agment", "asdf://host/pa'th?qu'ery#fr'agment"});
     // FIXME: Add more tests with other encodings and things like non-ascii characters, emoji and unmatched surrogate pairs.
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to