[whatwg/url] Defered validation error reporting in IPv4 parser (Issue #706)

After #619, the [IPv4 parser](https://url.spec.whatwg.org/#concept-ipv4-parser) now only returns an IPv4 address or failure. Previously, it returned it's input instead of failure in many cases. The only call to the IPv4 parser is now guarded by the [ends-in-a-number-checker](https://url.spec.whatwg.org/#ends-in-a-number-checker), which makes the following note outdated:

> This uses validationError to track [validation errors](https://url.spec.whatwg.org/#validation-error) to avoid reporting them before we are confident we want to parse input as an IPv4 address as the [host parser](https://url.spec.whatwg.org/#concept-host-parser) almost always invokes the [IPv4 parser](https://url.spec.whatwg.org/#concept-ipv4-parser).

The IPv4 parser essentially pauses validation error reporting in Step 1 and resumes reporting in Step 7. Step 3.1 sets `validationError` to `true`, but fails to report it if the parser returns failure before Step 7.

Step 3.1 should probably be changed to "validation error". This would leave the loop in Step 6 as the only place where `validationError` is set to `true`.

Is the IPv4 parser designed to be used without first running [ends-in-a-number-checker](https://url.spec.whatwg.org/#ends-in-a-number-checker)? Does the use of `validationError` still make sense?

Removing the last use of `validationError` and directly reporting a validation error in [ipv4-number-parser](https://url.spec.whatwg.org/#ipv4-number-parser) Step 4.1 and 5.1 would report a validation error for each part instead of a single validation error for the entire address. I don't know if that is desirable or not.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/706
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/url/issues/706@github.com>

Received on Saturday, 10 September 2022 01:25:29 UTC