From 05dcc02b1ef96f99f5c5c9d046fb97be7e4e3666 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 2 May 2022 09:55:46 +0200 Subject: [PATCH 1/2] url: revert "validate ipv4 part length" This reverts commit 87d0d7a069b2a3ca1db1dd592a62db4645ba5d69. Refs: https://github.com/nodejs/node/pull/42915 --- src/node_url.cc | 5 +---- .../fixtures/wpt/url/resources/urltestdata.json | 17 +++++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/node_url.cc b/src/node_url.cc index dbb51ef5ec00af..b13c94f030fa59 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -411,11 +411,8 @@ 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(arraysize(numbers))) { - *is_ipv4 = true; + if (++parts > static_cast(arraysize(numbers))) return; - } if (pointer == mark) return; int64_t n = ParseNumber(mark, pointer); diff --git a/test/fixtures/wpt/url/resources/urltestdata.json b/test/fixtures/wpt/url/resources/urltestdata.json index dc33048964a2f5..a56b30caf98cb1 100644 --- a/test/fixtures/wpt/url/resources/urltestdata.json +++ b/test/fixtures/wpt/url/resources/urltestdata.json @@ -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", From 7352d8b63207c07571a4139623867cae936e3808 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 2 May 2022 10:37:14 +0200 Subject: [PATCH 2/2] fixup! url: revert "validate ipv4 part length" --- src/node_url.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/node_url.cc b/src/node_url.cc index b13c94f030fa59..3cbe6ab5f354e2 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -411,8 +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 > static_cast(arraysize(numbers))) - return; + if (++parts > static_cast(arraysize(numbers))) return; if (pointer == mark) return; int64_t n = ParseNumber(mark, pointer);