Changeset 219024 in webkit


Ignore:
Timestamp:
Jun 30, 2017 4:21:51 PM (7 years ago)
Author:
achristensen@apple.com
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
<rdar://problem/33002846>

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):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r219023 r219024  
     12017-06-30  Alex Christensen  <achristensen@webkit.org>
     2
     3        REGRESSION(r215096) Queries of URLs with non-special schemes should not percent-encode single quotes
     4        https://bugs.webkit.org/show_bug.cgi?id=174051
     5        <rdar://problem/33002846>
     6
     7        Reviewed by Tim Horton.
     8
     9        In r215096 I added ' to the set of characters to be percent-encoded in queries,
     10        but for interoperability and compatibility we need to do this only for special schemes, like http.
     11
     12        Covered by new API tests.
     13
     14        * platform/URLParser.cpp:
     15        (WebCore::isC0Control):
     16        (WebCore::shouldPercentEncodeQueryByte):
     17        (WebCore::URLParser::utf8QueryEncode):
     18        (WebCore::URLParser::encodeQuery):
     19
    1202017-06-30  Daniel Bates  <dabates@apple.com>
    221
  • trunk/Source/WebCore/platform/URLParser.cpp

    r217860 r219024  
    192192    ForbiddenHost, // '%'
    193193    0, // '&'
    194     QueryPercent, // '''
     194    0, // '''
    195195    0, // '('
    196196    0, // ')'
     
    421421template<typename CharacterType> ALWAYS_INLINE static bool isValidSchemeCharacter(CharacterType character) { return character <= 'z' && characterClassTable[character] & ValidScheme; }
    422422template<typename CharacterType> ALWAYS_INLINE static bool isForbiddenHostCodePoint(CharacterType character) { return character <= ']' && characterClassTable[character] & ForbiddenHost; }
    423 static bool shouldPercentEncodeQueryByte(uint8_t byte) { return characterClassTable[byte] & QueryPercent; }
     423ALWAYS_INLINE static bool shouldPercentEncodeQueryByte(uint8_t byte, const bool& urlIsSpecial)
     424{
     425    if (characterClassTable[byte] & QueryPercent)
     426        return true;
     427    if (byte == '\'' && urlIsSpecial)
     428        return true;
     429    return false;
     430}
    424431
    425432template<typename CharacterType, URLParser::ReportSyntaxViolation reportSyntaxViolation>
     
    579586    UChar32 codePoint = *iterator;
    580587    if (LIKELY(isASCII(codePoint))) {
    581         if (UNLIKELY(shouldPercentEncodeQueryByte(codePoint))) {
     588        if (UNLIKELY(shouldPercentEncodeQueryByte(codePoint, m_urlIsSpecial))) {
    582589            syntaxViolation(iterator);
    583590            percentEncodeByte(codePoint);
     
    599606    for (int32_t i = 0; i < offset; ++i) {
    600607        auto byte = buffer[i];
    601         if (shouldPercentEncodeQueryByte(byte))
     608        if (shouldPercentEncodeQueryByte(byte, m_urlIsSpecial))
    602609            percentEncodeByte(byte);
    603610        else
     
    627634            break;
    628635        }
    629         if (UNLIKELY(shouldPercentEncodeQueryByte(byte))) {
     636        if (UNLIKELY(shouldPercentEncodeQueryByte(byte, m_urlIsSpecial))) {
    630637            syntaxViolation(iterator);
    631638            break;
     
    640647        ASSERT(m_didSeeSyntaxViolation);
    641648        uint8_t byte = data[i];
    642         if (shouldPercentEncodeQueryByte(byte))
     649        if (shouldPercentEncodeQueryByte(byte, m_urlIsSpecial))
    643650            percentEncodeByte(byte);
    644651        else
  • trunk/Tools/ChangeLog

    r219013 r219024  
     12017-06-30  Alex Christensen  <achristensen@webkit.org>
     2
     3        REGRESSION(r215096) Queries of URLs with non-special schemes should not percent-encode single quotes
     4        https://bugs.webkit.org/show_bug.cgi?id=174051
     5        <rdar://problem/33002846>
     6
     7        Reviewed by Tim Horton.
     8
     9        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
     10        (TestWebKitAPI::TEST_F):
     11
    1122017-06-30  Daniel Bates  <dabates@apple.com>
    213
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp

    r215096 r219024  
    12991299    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"});
    13001300
     1301    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"});
     1302    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"});
    13011303    checkURL("http://host/?query=foo'bar", UTF8Encoding(), {"http", "", "", "host", 0, "/", "query=foo%27bar", "", "http://host/?query=foo%27bar"});
    13021304    // FIXME: Add more tests with other encodings and things like non-ascii characters, emoji and unmatched surrogate pairs.
Note: See TracChangeset for help on using the changeset viewer.