Changeset 206942 in webkit
- Timestamp:
- Oct 7, 2016, 4:06:32 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r206941 r206942 1 2016-10-07 Alex Christensen <achristensen@webkit.org> 2 3 Non-special URL fragments should percent-encode non-ASCII characters 4 https://bugs.webkit.org/show_bug.cgi?id=163153 5 6 Reviewed by Tim Horton. 7 8 This is needed to keep compatibility with data URLs with non-ASCII characters after a '#' 9 which works in Chrome, Firefox, and Safari, while maintaining compatibility with Chrome, IE, and Edge 10 which keep non-ASCII characters in the fragments of special URLs. 11 This was proposed to the spec in https://github.com/whatwg/url/issues/150 12 13 Covered by new API tests. 14 15 * platform/URLParser.cpp: 16 (WebCore::URLParser::syntaxViolation): 17 Removed assertion because we now have fragments that need percent encoding but are all ASCII. 18 (WebCore::URLParser::fragmentSyntaxViolation): 19 (WebCore::URLParser::parse): 20 1 21 2016-10-07 Brent Fulgham <bfulgham@apple.com> 2 22 -
trunk/Source/WebCore/platform/URLParser.cpp
r206924 r206942 1020 1020 ASSERT(m_asciiBuffer.isEmpty()); 1021 1021 ASSERT(m_unicodeFragmentBuffer.isEmpty()); 1022 ASSERT_WITH_MESSAGE(!m_url.m_queryEnd, "syntaxViolation should not be used in the fragment, which might contain non-ASCII code points when serialized");1023 1022 size_t codeUnitsToCopy = iterator.codeUnitsSince(reinterpret_cast<const CharacterType*>(m_inputBegin)); 1024 1023 RELEASE_ASSERT(codeUnitsToCopy <= m_inputString.length()); … … 1033 1032 void URLParser::fragmentSyntaxViolation(const CodePointIterator<CharacterType>& iterator) 1034 1033 { 1034 ASSERT(m_didSeeUnicodeFragmentCodePoint); 1035 1035 if (m_didSeeSyntaxViolation) 1036 1036 return; 1037 1037 m_didSeeSyntaxViolation = true; 1038 m_didSeeUnicodeFragmentCodePoint = true;1039 1038 1040 1039 ASSERT(m_asciiBuffer.isEmpty()); … … 1815 1814 do { 1816 1815 URL_PARSER_LOG("State Fragment"); 1817 if (!m_didSeeUnicodeFragmentCodePoint && isASCII(*c)) 1818 appendToASCIIBuffer(*c); 1819 else { 1820 m_didSeeUnicodeFragmentCodePoint = true; 1821 if (UNLIKELY(m_didSeeSyntaxViolation)) 1822 appendCodePoint(m_unicodeFragmentBuffer, *c); 1823 else { 1824 ASSERT(m_asciiBuffer.isEmpty()); 1825 ASSERT(m_unicodeFragmentBuffer.isEmpty()); 1826 } 1816 if (!c.atEnd() && isTabOrNewline(*c)) { 1817 if (m_didSeeUnicodeFragmentCodePoint) 1818 fragmentSyntaxViolation(c); 1819 else 1820 syntaxViolation(c); 1821 ++c; 1822 continue; 1823 } 1824 if (!m_didSeeUnicodeFragmentCodePoint && isASCII(*c)) { 1825 if (m_urlIsSpecial) 1826 appendToASCIIBuffer(*c); 1827 else 1828 utf8PercentEncode<isInSimpleEncodeSet>(c); 1829 } else { 1830 if (m_urlIsSpecial) { 1831 m_didSeeUnicodeFragmentCodePoint = true; 1832 if (UNLIKELY(m_didSeeSyntaxViolation)) 1833 appendCodePoint(m_unicodeFragmentBuffer, *c); 1834 else { 1835 ASSERT(m_asciiBuffer.isEmpty()); 1836 ASSERT(m_unicodeFragmentBuffer.isEmpty()); 1837 } 1838 } else 1839 utf8PercentEncode<isInSimpleEncodeSet>(c); 1827 1840 } 1828 1841 ++c; 1829 while (UNLIKELY(!c.atEnd() && isTabOrNewline(*c))) {1830 fragmentSyntaxViolation(c);1831 ++c;1832 }1833 1842 } while (!c.atEnd()); 1834 1843 break; -
trunk/Tools/ChangeLog
r206940 r206942 1 2016-10-07 Alex Christensen <achristensen@webkit.org> 2 3 Non-special URL fragments should percent-encode non-ASCII characters 4 https://bugs.webkit.org/show_bug.cgi?id=163153 5 6 Reviewed by Tim Horton. 7 8 * TestWebKitAPI/Tests/WebCore/URLParser.cpp: 9 (TestWebKitAPI::TEST_F): 10 1 11 2016-10-07 Jonathan Bedard <jbedard@apple.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp
r206887 r206942 330 330 checkURL("A://", {"a", "", "", "", 0, "//", "", "", "a://"}); 331 331 checkURL("aA://", {"aa", "", "", "", 0, "//", "", "", "aa://"}); 332 checkURL(utf16String(u"foo://host/#ПП\u0007 a</"), {"foo", "", "", "host", 0, "/", "", "%D0%9F%D0%9F%07 a</", "foo://host/#%D0%9F%D0%9F%07 a</"}); 333 checkURL(utf16String(u"foo://host/#\u0007 a</"), {"foo", "", "", "host", 0, "/", "", "%07 a</", "foo://host/#%07 a</"}); 332 334 333 335 // This disagrees with the web platform test for http://:@www.example.com but agrees with Chrome and URL::parse, … … 1059 1061 {"", "", "", "", 0, "", "", "", "file://:0/path"}, 1060 1062 {"file", "", "", "", 0, "/path", "", "", "file://:0/path"}); 1063 checkURLDifferences(utf16String(u"http://host/#ПП\u0007 a</"), 1064 {"http", "", "", "host", 0, "/", "", utf16String(u"ПП\u0007 a</"), utf16String(u"http://host/#ПП\u0007 a</")}, 1065 {"http", "", "", "host", 0, "/", "", "%D0%9F%D0%9F%07 a</", "http://host/#%D0%9F%D0%9F%07 a</"}); 1066 checkURLDifferences(utf16String(u"http://host/#\u0007 a</"), 1067 {"http", "", "", "host", 0, "/", "", "\a a</", "http://host/#\a a</"}, 1068 {"http", "", "", "host", 0, "/", "", "%07 a</", "http://host/#%07 a</"}); 1061 1069 } 1062 1070
Note:
See TracChangeset
for help on using the changeset viewer.