Fix syntax violation handling in IPv4 address parsing
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2016 22:02:04 +0000 (22:02 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2016 22:02:04 +0000 (22:02 +0000)
commitb11ac7e42e74d279ab9ec5710a20a83492966c97
treecd726a82e90af3510e4e1efc815bbe1ed55a7aee
parent724267cc1efbb317c9bcf149600798b8475d2151
Fix syntax violation handling in IPv4 address parsing
https://bugs.webkit.org/show_bug.cgi?id=162756

Reviewed by Tim Horton.

Source/WebCore:

When we are parsing the up to 4 numbers in an IPv4 address, if we find a syntax violation
(the canonicalized address would be different than the input string) then wait to report
it until we have determined that this is a valid IPv4 address that will be canonicalized.
If it is not a valid IPv4 address, then we will just treat the characters as the host, and
that could be no syntax violation.

Covered by a new API test and existing API tests.

* platform/URLParser.cpp:
(WebCore::URLParser::URLParser):
(WebCore::URLParser::parseIPv4Number):
(WebCore::URLParser::parseIPv4Host):
* platform/URLParser.h:

Tools:

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

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206617 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/URLParser.cpp
Source/WebCore/platform/URLParser.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp