Log Message
URLParser: Handle windows drive letters after two slashes in relative URLs according to spec https://bugs.webkit.org/show_bug.cgi?id=162646
Reviewed by Saam Barati. Source/WebCore: Covered by new API tests. * platform/URLParser.cpp: (WebCore::CodePointIterator::codeUnitsSince): (WebCore::URLParser::appendWindowsDriveLetter): (WebCore::URLParser::parse): (WebCore::isWindowsDriveLetter): Deleted. (WebCore::URLParser::checkWindowsDriveLetter): Deleted. * platform/URLParser.h: Tools: * TestWebKitAPI/Tests/WebCore/URLParser.cpp: (TestWebKitAPI::TEST_F):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (206476 => 206477)
--- trunk/Source/WebCore/ChangeLog 2016-09-28 00:26:15 UTC (rev 206476)
+++ trunk/Source/WebCore/ChangeLog 2016-09-28 00:31:44 UTC (rev 206477)
@@ -1,5 +1,22 @@
2016-09-27 Alex Christensen <achristen...@webkit.org>
+ URLParser: Handle windows drive letters after two slashes in relative URLs according to spec
+ https://bugs.webkit.org/show_bug.cgi?id=162646
+
+ Reviewed by Saam Barati.
+
+ Covered by new API tests.
+
+ * platform/URLParser.cpp:
+ (WebCore::CodePointIterator::codeUnitsSince):
+ (WebCore::URLParser::appendWindowsDriveLetter):
+ (WebCore::URLParser::parse):
+ (WebCore::isWindowsDriveLetter): Deleted.
+ (WebCore::URLParser::checkWindowsDriveLetter): Deleted.
+ * platform/URLParser.h:
+
+2016-09-27 Alex Christensen <achristen...@webkit.org>
+
URLs with @ in the user should only search for the last @ until the end of the authority and host
https://bugs.webkit.org/show_bug.cgi?id=162635
Modified: trunk/Source/WebCore/platform/URLParser.cpp (206476 => 206477)
--- trunk/Source/WebCore/platform/URLParser.cpp 2016-09-28 00:26:15 UTC (rev 206476)
+++ trunk/Source/WebCore/platform/URLParser.cpp 2016-09-28 00:31:44 UTC (rev 206477)
@@ -77,6 +77,11 @@
ASSERT(m_begin >= reference);
return m_begin - reference;
}
+
+ size_t codeUnitsSince(const CodePointIterator& other) const
+ {
+ return codeUnitsSince(other.m_begin);
+ }
private:
const CharacterType* m_begin { nullptr };
@@ -436,13 +441,6 @@
return false;
}
-inline static bool isWindowsDriveLetter(const Vector<LChar>& buffer, size_t index)
-{
- if (buffer.size() < index + 2)
- return false;
- return isASCIIAlpha(buffer[index]) && (buffer[index + 1] == ':' || buffer[index + 1] == '|');
-}
-
void URLParser::appendToASCIIBuffer(UChar32 codePoint)
{
ASSERT(m_unicodeFragmentBuffer.isEmpty());
@@ -459,16 +457,15 @@
}
template<typename CharacterType>
-void URLParser::checkWindowsDriveLetter(CodePointIterator<CharacterType>& iterator)
+void URLParser::appendWindowsDriveLetter(CodePointIterator<CharacterType>& iterator)
{
- if (isWindowsDriveLetter(iterator)) {
- appendToASCIIBuffer(*iterator);
- advance(iterator);
- ASSERT(!iterator.atEnd());
- ASSERT(*iterator == ':' || *iterator == '|');
- appendToASCIIBuffer(':');
- advance(iterator);
- }
+ ASSERT(isWindowsDriveLetter(iterator));
+ appendToASCIIBuffer(*iterator);
+ advance(iterator);
+ ASSERT(!iterator.atEnd());
+ ASSERT(*iterator == ':' || *iterator == '|');
+ appendToASCIIBuffer(':');
+ advance(iterator);
}
template<typename CharacterType>
@@ -1409,7 +1406,8 @@
m_url.m_hostEnd = m_url.m_userStart;
m_url.m_portEnd = m_url.m_userStart;
m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
- checkWindowsDriveLetter(c);
+ if (isWindowsDriveLetter(c))
+ appendWindowsDriveLetter(c);
}
state = State::Path;
break;
@@ -1452,18 +1450,21 @@
m_url.m_hostEnd = m_url.m_userStart;
m_url.m_portEnd = m_url.m_userStart;
m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
- checkWindowsDriveLetter(c);
+ if (isWindowsDriveLetter(c))
+ appendWindowsDriveLetter(c);
state = State::Path;
break;
case State::FileHost:
LOG_STATE("FileHost");
if (isSlashQuestionOrHash(*c)) {
- if (WebCore::isWindowsDriveLetter(m_asciiBuffer, m_url.m_portEnd + 1)) {
- state = State::Path;
- break;
+ bool windowsQuirk = c.codeUnitsSince(authorityOrHostBegin) == 2 && isWindowsDriveLetter(authorityOrHostBegin);
+ if (windowsQuirk) {
+ syntaxViolation(authorityOrHostBegin);
+ appendToASCIIBuffer('/');
+ appendWindowsDriveLetter(authorityOrHostBegin);
}
- if (authorityOrHostBegin == c) {
- ASSERT(parsedDataView(currentPosition(c) - 1, 1) == "/");
+ if (windowsQuirk || authorityOrHostBegin == c) {
+ ASSERT(windowsQuirk || parsedDataView(currentPosition(c) - 1, 1) == "/");
if (UNLIKELY(*c == '?')) {
syntaxViolation(c);
appendToASCIIBuffer("/?", 2);
Modified: trunk/Source/WebCore/platform/URLParser.h (206476 => 206477)
--- trunk/Source/WebCore/platform/URLParser.h 2016-09-28 00:26:15 UTC (rev 206476)
+++ trunk/Source/WebCore/platform/URLParser.h 2016-09-28 00:31:44 UTC (rev 206477)
@@ -72,7 +72,7 @@
template<typename CharacterType> void fragmentSyntaxViolation(const CodePointIterator<CharacterType>&);
template<typename CharacterType> bool isWindowsDriveLetter(CodePointIterator<CharacterType>);
template<typename CharacterType> bool shouldCopyFileURL(CodePointIterator<CharacterType>);
- template<typename CharacterType> void checkWindowsDriveLetter(CodePointIterator<CharacterType>&);
+ template<typename CharacterType> void appendWindowsDriveLetter(CodePointIterator<CharacterType>&);
template<typename CharacterType> size_t currentPosition(const CodePointIterator<CharacterType>&);
template<typename UnsignedIntegerType> void appendNumberToASCIIBuffer(UnsignedIntegerType);
template<bool(*isInCodeSet)(UChar32), typename CharacterType> void utf8PercentEncode(const CodePointIterator<CharacterType>&);
Modified: trunk/Tools/ChangeLog (206476 => 206477)
--- trunk/Tools/ChangeLog 2016-09-28 00:26:15 UTC (rev 206476)
+++ trunk/Tools/ChangeLog 2016-09-28 00:31:44 UTC (rev 206477)
@@ -1,5 +1,15 @@
2016-09-27 Alex Christensen <achristen...@webkit.org>
+ URLParser: Handle windows drive letters after two slashes in relative URLs according to spec
+ https://bugs.webkit.org/show_bug.cgi?id=162646
+
+ Reviewed by Saam Barati.
+
+ * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+ (TestWebKitAPI::TEST_F):
+
+2016-09-27 Alex Christensen <achristen...@webkit.org>
+
URLs with @ in the user should only search for the last @ until the end of the authority and host
https://bugs.webkit.org/show_bug.cgi?id=162635
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (206476 => 206477)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2016-09-28 00:26:15 UTC (rev 206476)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2016-09-28 00:31:44 UTC (rev 206477)
@@ -651,6 +651,18 @@
checkURLDifferences("A://",
{"a", "", "", "", 0, "/", "", "", "a:///"},
{"a", "", "", "", 0, "//", "", "", "a://"});
+ checkRelativeURLDifferences("//C|/foo/bar", "file:///tmp/mock/path",
+ {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"},
+ {"", "", "", "", 0, "", "", "", "//C|/foo/bar"});
+ checkRelativeURLDifferences("//C:/foo/bar", "file:///tmp/mock/path",
+ {"file", "", "", "", 0, "/C:/foo/bar", "", "", "file:///C:/foo/bar"},
+ {"file", "", "", "c", 0, "/foo/bar", "", "", "file://c/foo/bar"});
+ checkRelativeURLDifferences("//C|?foo/bar", "file:///tmp/mock/path",
+ {"file", "", "", "", 0, "/C:/", "foo/bar", "", "file:///C:/?foo/bar"},
+ {"", "", "", "", 0, "", "", "", "//C|?foo/bar"});
+ checkRelativeURLDifferences("//C|#foo/bar", "file:///tmp/mock/path",
+ {"file", "", "", "", 0, "/C:/", "", "foo/bar", "file:///C:/#foo/bar"},
+ {"", "", "", "", 0, "", "", "", "//C|#foo/bar"});
}
TEST_F(URLParserTest, DefaultPort)
@@ -790,6 +802,7 @@
shouldFail("://:0/", "");
shouldFail("://:0/", "about:blank");
shouldFail("about~");
+ shouldFail("//C:asdf/foo/bar", "file:///tmp/mock/path");
}
// These are in the spec but not in the web platform tests.
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes