Skip to content

Commit

Permalink
url: revert "validate ipv4 part length"
Browse files Browse the repository at this point in the history
This reverts commit 87d0d7a.

Refs: #42915

PR-URL: #42940
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
aduh95 authored May 5, 2022
1 parent f7d658a commit a3ff4bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
6 changes: 1 addition & 5 deletions src/node_url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,7 @@ void URLHost::ParseIPv4Host(const char* input, size_t length, bool* is_ipv4) {
const char ch = pointer < end ? pointer[0] : kEOL;
int64_t remaining = end - pointer - 1;
if (ch == '.' || ch == kEOL) {
// If parts’s size is greater than 4, validation error, return failure.
if (++parts > static_cast<int>(arraysize(numbers))) {
*is_ipv4 = true;
return;
}
if (++parts > static_cast<int>(arraysize(numbers))) return;
if (pointer == mark)
return;
int64_t n = ParseNumber(mark, pointer);
Expand Down
17 changes: 11 additions & 6 deletions test/fixtures/wpt/url/resources/urltestdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5317,12 +5317,17 @@
{
"input": "http://256.256.256.256.256",
"base": "http://other.com/",
"failure": true
},
{
"input": "http://256.256.256.256.256.",
"base": "http://other.com/",
"failure": true
"href": "http://256.256.256.256.256/",
"origin": "http://256.256.256.256.256",
"protocol": "http:",
"username": "",
"password": "",
"host": "256.256.256.256.256",
"hostname": "256.256.256.256.256",
"port": "",
"pathname": "/",
"search": "",
"hash": ""
},
{
"input": "https://0x.0x.0",
Expand Down

0 comments on commit a3ff4bf

Please sign in to comment.