Log Message
URLs with an invalid IPv4 address should be invalid https://bugs.webkit.org/show_bug.cgi?id=168260
Reviewed by Tim Horton. LayoutTests/imported/w3c: * web-platform-tests/url/a-element-expected.txt: * web-platform-tests/url/a-element-xhtml-expected.txt: * web-platform-tests/url/url-constructor-expected.txt: Source/WebCore: All URL hosts are fed through the IPv4 parser. https://webkit.org/ doesn't look enough like an IPv4 address to be considered an invalid IPv4 address, so we continue to the String host processing. http://127.0.0.257 does, though, and according to https://url.spec.whatwg.org/#concept-ipv4-parser parsing that URL should fail. Covered by newly passing web platform tests. * platform/URLParser.cpp: (WebCore::URLParser::parseIPv4Host): (WebCore::URLParser::parseHostAndPort): * platform/URLParser.h: Source/WTF: * wtf/Expected.h: (WTF::Expected::value): Added missing WTFMove for rvalue Expected::value(). Tools: * TestWebKitAPI/Tests/WebCore/URLParser.cpp: (TestWebKitAPI::TEST_F): Update tests to reflect new correct behavior. LayoutTests: * fetch/fetch-url-serialization-expected.txt:
Modified Paths
- trunk/LayoutTests/ChangeLog
- trunk/LayoutTests/fetch/fetch-url-serialization-expected.txt
- trunk/LayoutTests/imported/w3c/ChangeLog
- trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt
- trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt
- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt
- trunk/Source/WTF/ChangeLog
- trunk/Source/WTF/wtf/Expected.h
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/platform/URLParser.cpp
- trunk/Source/WebCore/platform/URLParser.h
- trunk/Tools/ChangeLog
- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp
Diff
Modified: trunk/LayoutTests/ChangeLog (212278 => 212279)
--- trunk/LayoutTests/ChangeLog 2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/LayoutTests/ChangeLog 2017-02-14 07:43:28 UTC (rev 212279)
@@ -1,3 +1,12 @@
+2017-02-13 Alex Christensen <achristen...@webkit.org>
+
+ URLs with an invalid IPv4 address should be invalid
+ https://bugs.webkit.org/show_bug.cgi?id=168260
+
+ Reviewed by Tim Horton.
+
+ * fetch/fetch-url-serialization-expected.txt:
+
2017-02-13 Karim H <ka...@karhm.com>
Added the BSTR roles tag test for Windows.
Modified: trunk/LayoutTests/fetch/fetch-url-serialization-expected.txt (212278 => 212279)
--- trunk/LayoutTests/fetch/fetch-url-serialization-expected.txt 2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/LayoutTests/fetch/fetch-url-serialization-expected.txt 2017-02-14 07:43:28 UTC (rev 212279)
@@ -264,7 +264,7 @@
PASS Testing Request url 'http://hello%00' with base 'http://other.com/'
PASS Testing Request url 'http://%30%78%63%30%2e%30%32%35%30.01' with base 'http://other.com/'
PASS Testing Request url 'http://%30%78%63%30%2e%30%32%35%30.01%2e' with base 'http://other.com/'
-FAIL Testing Request url 'http://192.168.0.257' with base 'http://other.com/' assert_throws: function "function () { new Request(url.input); }" did not throw
+PASS Testing Request url 'http://192.168.0.257' with base 'http://other.com/'
PASS Testing Request url 'http://%3g%78%63%30%2e%30%32%35%30%2E.01' with base 'http://other.com/'
PASS Testing Request url 'http://192.168.0.1 hello' with base 'http://other.com/'
PASS Testing Request url 'http://0Xc0.0250.01' with base 'http://other.com/'
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (212278 => 212279)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2017-02-14 07:43:28 UTC (rev 212279)
@@ -1,5 +1,16 @@
2017-02-13 Alex Christensen <achristen...@webkit.org>
+ URLs with an invalid IPv4 address should be invalid
+ https://bugs.webkit.org/show_bug.cgi?id=168260
+
+ Reviewed by Tim Horton.
+
+ * web-platform-tests/url/a-element-expected.txt:
+ * web-platform-tests/url/a-element-xhtml-expected.txt:
+ * web-platform-tests/url/url-constructor-expected.txt:
+
+2017-02-13 Alex Christensen <achristen...@webkit.org>
+
Percent should be allowed in non-special URL hosts
https://bugs.webkit.org/show_bug.cgi?id=168255
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt (212278 => 212279)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt 2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt 2017-02-14 07:43:28 UTC (rev 212279)
@@ -278,7 +278,7 @@
PASS Parsing: <http://hello%00> against <http://other.com/>
PASS Parsing: <http://%30%78%63%30%2e%30%32%35%30.01> against <http://other.com/>
PASS Parsing: <http://%30%78%63%30%2e%30%32%35%30.01%2e> against <http://other.com/>
-FAIL Parsing: <http://192.168.0.257> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
+PASS Parsing: <http://192.168.0.257> against <http://other.com/>
PASS Parsing: <http://%3g%78%63%30%2e%30%32%35%30%2E.01> against <http://other.com/>
PASS Parsing: <http://192.168.0.1 hello> against <http://other.com/>
PASS Parsing: <http://0Xc0.0250.01> against <http://other.com/>
@@ -372,13 +372,13 @@
PASS Parsing: <http://256.com> against <http://other.com/>
PASS Parsing: <http://999999999> against <http://other.com/>
PASS Parsing: <http://999999999.com> against <http://other.com/>
-FAIL Parsing: <http://10000000000> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
+PASS Parsing: <http://10000000000> against <http://other.com/>
PASS Parsing: <http://10000000000.com> against <http://other.com/>
PASS Parsing: <http://4294967295> against <http://other.com/>
-FAIL Parsing: <http://4294967296> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
+PASS Parsing: <http://4294967296> against <http://other.com/>
PASS Parsing: <http://0xffffffff> against <http://other.com/>
-FAIL Parsing: <http://0xffffffff1> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
-FAIL Parsing: <http://256.256.256.256> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
+PASS Parsing: <http://0xffffffff1> against <http://other.com/>
+PASS Parsing: <http://256.256.256.256> against <http://other.com/>
PASS Parsing: <http://256.256.256.256.256> against <http://other.com/>
PASS Parsing: <file:///C%3A/> against <about:blank>
PASS Parsing: <file:///C%7C/> against <about:blank>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt (212278 => 212279)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt 2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt 2017-02-14 07:43:28 UTC (rev 212279)
@@ -278,7 +278,7 @@
PASS Parsing: <http://hello%00> against <http://other.com/>
PASS Parsing: <http://%30%78%63%30%2e%30%32%35%30.01> against <http://other.com/>
PASS Parsing: <http://%30%78%63%30%2e%30%32%35%30.01%2e> against <http://other.com/>
-FAIL Parsing: <http://192.168.0.257> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
+PASS Parsing: <http://192.168.0.257> against <http://other.com/>
PASS Parsing: <http://%3g%78%63%30%2e%30%32%35%30%2E.01> against <http://other.com/>
PASS Parsing: <http://192.168.0.1 hello> against <http://other.com/>
PASS Parsing: <http://0Xc0.0250.01> against <http://other.com/>
@@ -372,13 +372,13 @@
PASS Parsing: <http://256.com> against <http://other.com/>
PASS Parsing: <http://999999999> against <http://other.com/>
PASS Parsing: <http://999999999.com> against <http://other.com/>
-FAIL Parsing: <http://10000000000> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
+PASS Parsing: <http://10000000000> against <http://other.com/>
PASS Parsing: <http://10000000000.com> against <http://other.com/>
PASS Parsing: <http://4294967295> against <http://other.com/>
-FAIL Parsing: <http://4294967296> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
+PASS Parsing: <http://4294967296> against <http://other.com/>
PASS Parsing: <http://0xffffffff> against <http://other.com/>
-FAIL Parsing: <http://0xffffffff1> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
-FAIL Parsing: <http://256.256.256.256> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
+PASS Parsing: <http://0xffffffff1> against <http://other.com/>
+PASS Parsing: <http://256.256.256.256> against <http://other.com/>
PASS Parsing: <http://256.256.256.256.256> against <http://other.com/>
PASS Parsing: <file:///C%3A/> against <about:blank>
PASS Parsing: <file:///C%7C/> against <about:blank>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt (212278 => 212279)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt 2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt 2017-02-14 07:43:28 UTC (rev 212279)
@@ -284,9 +284,7 @@
PASS Parsing: <http://hello%00> against <http://other.com/>
PASS Parsing: <http://%30%78%63%30%2e%30%32%35%30.01> against <http://other.com/>
PASS Parsing: <http://%30%78%63%30%2e%30%32%35%30.01%2e> against <http://other.com/>
-FAIL Parsing: <http://192.168.0.257> against <http://other.com/> assert_throws: function "function () {
- bURL(expected.input, expected.base)
- }" did not throw
+PASS Parsing: <http://192.168.0.257> against <http://other.com/>
PASS Parsing: <http://%3g%78%63%30%2e%30%32%35%30%2E.01> against <http://other.com/>
PASS Parsing: <http://192.168.0.1 hello> against <http://other.com/>
PASS Parsing: <http://0Xc0.0250.01> against <http://other.com/>
@@ -382,21 +380,13 @@
PASS Parsing: <http://256.com> against <http://other.com/>
PASS Parsing: <http://999999999> against <http://other.com/>
PASS Parsing: <http://999999999.com> against <http://other.com/>
-FAIL Parsing: <http://10000000000> against <http://other.com/> assert_throws: function "function () {
- bURL(expected.input, expected.base)
- }" did not throw
+PASS Parsing: <http://10000000000> against <http://other.com/>
PASS Parsing: <http://10000000000.com> against <http://other.com/>
PASS Parsing: <http://4294967295> against <http://other.com/>
-FAIL Parsing: <http://4294967296> against <http://other.com/> assert_throws: function "function () {
- bURL(expected.input, expected.base)
- }" did not throw
+PASS Parsing: <http://4294967296> against <http://other.com/>
PASS Parsing: <http://0xffffffff> against <http://other.com/>
-FAIL Parsing: <http://0xffffffff1> against <http://other.com/> assert_throws: function "function () {
- bURL(expected.input, expected.base)
- }" did not throw
-FAIL Parsing: <http://256.256.256.256> against <http://other.com/> assert_throws: function "function () {
- bURL(expected.input, expected.base)
- }" did not throw
+PASS Parsing: <http://0xffffffff1> against <http://other.com/>
+PASS Parsing: <http://256.256.256.256> against <http://other.com/>
PASS Parsing: <http://256.256.256.256.256> against <http://other.com/>
PASS Parsing: <file:///C%3A/> against <about:blank>
PASS Parsing: <file:///C%7C/> against <about:blank>
Modified: trunk/Source/WTF/ChangeLog (212278 => 212279)
--- trunk/Source/WTF/ChangeLog 2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/Source/WTF/ChangeLog 2017-02-14 07:43:28 UTC (rev 212279)
@@ -1,3 +1,14 @@
+2017-02-13 Alex Christensen <achristen...@webkit.org>
+
+ URLs with an invalid IPv4 address should be invalid
+ https://bugs.webkit.org/show_bug.cgi?id=168260
+
+ Reviewed by Tim Horton.
+
+ * wtf/Expected.h:
+ (WTF::Expected::value):
+ Added missing WTFMove for rvalue Expected::value().
+
2017-02-13 Said Abou-Hallawa <sabouhall...@apple.com>
The current frame of an image should not deleted if another frame is asynchronously being decoded
Modified: trunk/Source/WTF/wtf/Expected.h (212278 => 212279)
--- trunk/Source/WTF/wtf/Expected.h 2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/Source/WTF/wtf/Expected.h 2017-02-14 07:43:28 UTC (rev 212279)
@@ -315,7 +315,7 @@
constexpr const ValueType& value() const & { return base::has ? base::s.val : (ExpectedDetail::Throw(), base::s.val); }
RELAXED_CONSTEXPR ValueType& value() & { return base::has ? base::s.val : (ExpectedDetail::Throw(), base::s.val); }
constexpr const ValueType&& value() const && { return base::has ? base::s.val : (ExpectedDetail::Throw(), base::s.val); }
- RELAXED_CONSTEXPR ValueType&& value() && { return base::has ? base::s.val : (ExpectedDetail::Throw(), base::s.val); }
+ RELAXED_CONSTEXPR ValueType&& value() && { return WTFMove(base::has ? base::s.val : (ExpectedDetail::Throw(), base::s.val)); }
constexpr const ErrorType& error() const & { return !base::has ? base::s.err : (ExpectedDetail::Throw(), base::s.err); }
ErrorType& error() & { return !base::has ? base::s.err : (ExpectedDetail::Throw(), base::s.err); }
RELAXED_CONSTEXPR ErrorType&& error() && { return !base::has ? base::s.err : (ExpectedDetail::Throw(), base::s.err); }
Modified: trunk/Source/WebCore/ChangeLog (212278 => 212279)
--- trunk/Source/WebCore/ChangeLog 2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/Source/WebCore/ChangeLog 2017-02-14 07:43:28 UTC (rev 212279)
@@ -1,3 +1,23 @@
+2017-02-13 Alex Christensen <achristen...@webkit.org>
+
+ URLs with an invalid IPv4 address should be invalid
+ https://bugs.webkit.org/show_bug.cgi?id=168260
+
+ Reviewed by Tim Horton.
+
+ All URL hosts are fed through the IPv4 parser. https://webkit.org/ doesn't
+ look enough like an IPv4 address to be considered an invalid IPv4 address, so
+ we continue to the String host processing. http://127.0.0.257 does, though, and
+ according to https://url.spec.whatwg.org/#concept-ipv4-parser parsing that URL
+ should fail.
+
+ Covered by newly passing web platform tests.
+
+ * platform/URLParser.cpp:
+ (WebCore::URLParser::parseIPv4Host):
+ (WebCore::URLParser::parseHostAndPort):
+ * platform/URLParser.h:
+
2017-02-13 Dan Bernstein <m...@apple.com>
Reverted r212275. It still breaks some Apple-internal builds.
Modified: trunk/Source/WebCore/platform/URLParser.cpp (212278 => 212279)
--- trunk/Source/WebCore/platform/URLParser.cpp 2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/Source/WebCore/platform/URLParser.cpp 2017-02-14 07:43:28 UTC (rev 212279)
@@ -2130,8 +2130,13 @@
appendToASCIIBuffer(']');
}
+enum class URLParser::IPv4PieceParsingError {
+ Failure,
+ Overflow,
+};
+
template<typename CharacterType>
-std::optional<uint32_t> URLParser::parseIPv4Piece(CodePointIterator<CharacterType>& iterator, bool& didSeeSyntaxViolation)
+Expected<uint32_t, URLParser::IPv4PieceParsingError> URLParser::parseIPv4Piece(CodePointIterator<CharacterType>& iterator, bool& didSeeSyntaxViolation)
{
enum class State : uint8_t {
UnknownBase,
@@ -2143,7 +2148,7 @@
State state = State::UnknownBase;
Checked<uint32_t, RecordOverflow> value = 0;
if (!iterator.atEnd() && *iterator == '.')
- return std::nullopt;
+ return makeUnexpected(IPv4PieceParsingError::Failure);
while (!iterator.atEnd()) {
if (isTabOrNewline(*iterator)) {
didSeeSyntaxViolation = true;
@@ -2174,31 +2179,31 @@
break;
case State::Decimal:
if (!isASCIIDigit(*iterator))
- return std::nullopt;
+ return makeUnexpected(IPv4PieceParsingError::Failure);
value *= 10;
value += *iterator - '0';
if (UNLIKELY(value.hasOverflowed()))
- return std::nullopt;
+ return makeUnexpected(IPv4PieceParsingError::Overflow);
++iterator;
break;
case State::Octal:
ASSERT(didSeeSyntaxViolation);
if (*iterator < '0' || *iterator > '7')
- return std::nullopt;
+ return makeUnexpected(IPv4PieceParsingError::Failure);
value *= 8;
value += *iterator - '0';
if (UNLIKELY(value.hasOverflowed()))
- return std::nullopt;
+ return makeUnexpected(IPv4PieceParsingError::Overflow);
++iterator;
break;
case State::Hex:
ASSERT(didSeeSyntaxViolation);
if (!isASCIIHexDigit(*iterator))
- return std::nullopt;
+ return makeUnexpected(IPv4PieceParsingError::Failure);
value *= 16;
value += toASCIIHexValue(*iterator);
if (UNLIKELY(value.hasOverflowed()))
- return std::nullopt;
+ return makeUnexpected(IPv4PieceParsingError::Overflow);
++iterator;
break;
}
@@ -2214,12 +2219,18 @@
return values[exponent];
}
+enum class URLParser::IPv4ParsingError {
+ Failure,
+ NotIPv4,
+};
+
template<typename CharacterTypeForSyntaxViolation, typename CharacterType>
-std::optional<URLParser::IPv4Address> URLParser::parseIPv4Host(const CodePointIterator<CharacterTypeForSyntaxViolation>& iteratorForSyntaxViolationPosition, CodePointIterator<CharacterType> iterator)
+Expected<URLParser::IPv4Address, URLParser::IPv4ParsingError> URLParser::parseIPv4Host(const CodePointIterator<CharacterTypeForSyntaxViolation>& iteratorForSyntaxViolationPosition, CodePointIterator<CharacterType> iterator)
{
- Vector<uint32_t, 4> items;
- items.reserveInitialCapacity(4);
+ Vector<Expected<uint32_t, URLParser::IPv4PieceParsingError>, 4> items;
bool didSeeSyntaxViolation = false;
+ if (!iterator.atEnd() && *iterator == '.')
+ return makeUnexpected(IPv4ParsingError::NotIPv4);
while (!iterator.atEnd()) {
if (isTabOrNewline(*iterator)) {
didSeeSyntaxViolation = true;
@@ -2227,35 +2238,39 @@
continue;
}
if (items.size() >= 4)
- return std::nullopt;
- if (auto item = parseIPv4Piece(iterator, didSeeSyntaxViolation))
- items.append(item.value());
- else
- return std::nullopt;
- if (!iterator.atEnd()) {
- if (items.size() >= 4)
- return std::nullopt;
- if (*iterator == '.')
- ++iterator;
- else
- return std::nullopt;
+ return makeUnexpected(IPv4ParsingError::NotIPv4);
+ items.append(parseIPv4Piece(iterator, didSeeSyntaxViolation));
+ if (!iterator.atEnd() && *iterator == '.') {
+ ++iterator;
+ if (iterator.atEnd())
+ syntaxViolation(iteratorForSyntaxViolationPosition);
+ else if (*iterator == '.')
+ return makeUnexpected(IPv4ParsingError::NotIPv4);
}
}
if (!iterator.atEnd() || !items.size() || items.size() > 4)
- return std::nullopt;
+ return makeUnexpected(IPv4ParsingError::NotIPv4);
+ for (const auto& item : items) {
+ if (!item.hasValue() && item.error() == IPv4PieceParsingError::Failure)
+ return makeUnexpected(IPv4ParsingError::NotIPv4);
+ }
+ for (const auto& item : items) {
+ if (!item.hasValue() && item.error() == IPv4PieceParsingError::Overflow)
+ return makeUnexpected(IPv4ParsingError::Failure);
+ }
if (items.size() > 1) {
for (size_t i = 0; i < items.size() - 1; i++) {
- if (items[i] > 255)
- return std::nullopt;
+ if (items[i].value() > 255)
+ return makeUnexpected(IPv4ParsingError::Failure);
}
}
- if (items[items.size() - 1] >= pow256(5 - items.size()))
- return std::nullopt;
+ if (items[items.size() - 1].value() >= pow256(5 - items.size()))
+ return makeUnexpected(IPv4ParsingError::Failure);
if (didSeeSyntaxViolation)
syntaxViolation(iteratorForSyntaxViolationPosition);
- for (auto item : items) {
- if (item > 255)
+ for (const auto& item : items) {
+ if (item.value() > 255)
syntaxViolation(iteratorForSyntaxViolationPosition);
}
@@ -2262,9 +2277,9 @@
if (UNLIKELY(items.size() != 4))
syntaxViolation(iteratorForSyntaxViolationPosition);
- IPv4Address ipv4 = items.takeLast();
+ IPv4Address ipv4 = items.takeLast().value();
for (size_t counter = 0; counter < items.size(); ++counter)
- ipv4 += items[counter] * pow256(3 - counter);
+ ipv4 += items[counter].value() * pow256(3 - counter);
return ipv4;
}
@@ -2634,7 +2649,8 @@
if (isForbiddenHostCodePoint(*iterator))
return false;
}
- if (auto address = parseIPv4Host(hostIterator, CodePointIterator<CharacterType>(hostIterator, iterator))) {
+ auto address = parseIPv4Host(hostIterator, CodePointIterator<CharacterType>(hostIterator, iterator));
+ if (address) {
serializeIPv4(address.value());
m_url.m_hostEnd = currentPosition(iterator);
if (iterator.atEnd()) {
@@ -2643,6 +2659,8 @@
}
return parsePort(iterator);
}
+ if (address.error() == IPv4ParsingError::Failure)
+ return false;
for (; hostIterator != iterator; ++hostIterator) {
if (UNLIKELY(isTabOrNewline(*hostIterator))) {
syntaxViolation(hostIterator);
@@ -2692,7 +2710,8 @@
Vector<LChar, defaultInlineBufferSize>& asciiDomainValue = asciiDomain.value();
const LChar* asciiDomainCharacters = asciiDomainValue.data();
- if (auto address = parseIPv4Host(hostBegin, CodePointIterator<LChar>(asciiDomainValue.begin(), asciiDomainValue.end()))) {
+ auto address = parseIPv4Host(hostBegin, CodePointIterator<LChar>(asciiDomainValue.begin(), asciiDomainValue.end()));
+ if (address) {
serializeIPv4(address.value());
m_url.m_hostEnd = currentPosition(iterator);
if (iterator.atEnd()) {
@@ -2701,6 +2720,8 @@
}
return parsePort(iterator);
}
+ if (address.error() == IPv4ParsingError::Failure)
+ return false;
appendToASCIIBuffer(asciiDomainCharacters, asciiDomainValue.size());
m_url.m_hostEnd = currentPosition(iterator);
Modified: trunk/Source/WebCore/platform/URLParser.h (212278 => 212279)
--- trunk/Source/WebCore/platform/URLParser.h 2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/Source/WebCore/platform/URLParser.h 2017-02-14 07:43:28 UTC (rev 212279)
@@ -27,6 +27,7 @@
#include "TextEncoding.h"
#include "URL.h"
+#include <wtf/Expected.h>
#include <wtf/Forward.h>
struct UIDNA;
@@ -110,8 +111,10 @@
using IPv4Address = uint32_t;
void serializeIPv4(IPv4Address);
- template<typename CharacterTypeForSyntaxViolation, typename CharacterType> std::optional<IPv4Address> parseIPv4Host(const CodePointIterator<CharacterTypeForSyntaxViolation>&, CodePointIterator<CharacterType>);
- template<typename CharacterType> std::optional<uint32_t> parseIPv4Piece(CodePointIterator<CharacterType>&, bool& syntaxViolation);
+ enum class IPv4ParsingError;
+ enum class IPv4PieceParsingError;
+ template<typename CharacterTypeForSyntaxViolation, typename CharacterType> Expected<IPv4Address, IPv4ParsingError> parseIPv4Host(const CodePointIterator<CharacterTypeForSyntaxViolation>&, CodePointIterator<CharacterType>);
+ template<typename CharacterType> Expected<uint32_t, URLParser::IPv4PieceParsingError> parseIPv4Piece(CodePointIterator<CharacterType>&, bool& syntaxViolation);
using IPv6Address = std::array<uint16_t, 8>;
template<typename CharacterType> std::optional<IPv6Address> parseIPv6Host(CodePointIterator<CharacterType>);
template<typename CharacterType> std::optional<uint32_t> parseIPv4PieceInsideIPv6(CodePointIterator<CharacterType>&);
Modified: trunk/Tools/ChangeLog (212278 => 212279)
--- trunk/Tools/ChangeLog 2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/Tools/ChangeLog 2017-02-14 07:43:28 UTC (rev 212279)
@@ -1,3 +1,14 @@
+2017-02-13 Alex Christensen <achristen...@webkit.org>
+
+ URLs with an invalid IPv4 address should be invalid
+ https://bugs.webkit.org/show_bug.cgi?id=168260
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+ (TestWebKitAPI::TEST_F):
+ Update tests to reflect new correct behavior.
+
2017-02-13 Don Olmstead <don.olmst...@am.sony.com>
[WinCairo] Add Build Slave
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (212278 => 212279)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp 2017-02-14 07:43:28 UTC (rev 212279)
@@ -493,11 +493,22 @@
checkURL("http://\t//\\///user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://u...@webkit.org:99/?foo"});
checkURL("http:/\\user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://u...@webkit.org:99/?foo"});
checkURL("http://127.0.0.1", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
- checkURL("http://127.0.0.1.", {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
- checkURL("http://127.0.0.1./", {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
- checkURL("http://0x100.0/", {"http", "", "", "0x100.0", 0, "/", "", "", "http://0x100.0/"});
- checkURL("http://0.0.0x100.0/", {"http", "", "", "0.0.0x100.0", 0, "/", "", "", "http://0.0.0x100.0/"});
- checkURL("http://0.0.0.0x100/", {"http", "", "", "0.0.0.0x100", 0, "/", "", "", "http://0.0.0.0x100/"});
+ checkURLDifferences("http://127.0.0.1.",
+ {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"},
+ {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
+ checkURLDifferences("http://127.0.0.1./",
+ {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"},
+ {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
+ checkURL("http://127.0.0.1../", {"http", "", "", "127.0.0.1..", 0, "/", "", "", "http://127.0.0.1../"});
+ checkURLDifferences("http://0x100.0/",
+ {"", "", "", "", 0, "", "", "", "http://0x100.0/"},
+ {"http", "", "", "0x100.0", 0, "/", "", "", "http://0x100.0/"});
+ checkURLDifferences("http://0.0.0x100.0/",
+ {"", "", "", "", 0, "", "", "", "http://0.0.0x100.0/"},
+ {"http", "", "", "0.0.0x100.0", 0, "/", "", "", "http://0.0.0x100.0/"});
+ checkURLDifferences("http://0.0.0.0x100/",
+ {"", "", "", "", 0, "", "", "", "http://0.0.0.0x100/"},
+ {"http", "", "", "0.0.0.0x100", 0, "/", "", "", "http://0.0.0.0x100/"});
checkURL("http://host:123?", {"http", "", "", "host", 123, "/", "", "", "http://host:123/?"});
checkURL("http://host:123?query", {"http", "", "", "host", 123, "/", "query", "", "http://host:123/?query"});
checkURL("http://host:123#", {"http", "", "", "host", 123, "/", "", "", "http://host:123/#"});
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes