Repository navigation
feat(url): parsec-url failed 875 WPT cases and trailed Ada on speed - #86
Merged
Merged
Conversation
parsec-url wrapped the url and idna crates, which pass 3,690 of the 4,565 web-platform-tests URL cases (795 of the failures are the June 2026 rule that keeps an ASCII domain as written) and take 1.25 times as long as Ada on the links in the benchmark pages. It now has a WHATWG URL parser of its own behind the same API, written from the standard's current text: the state machine, host parsing (domains, IPv4 with the ends-in-a-number rule, IPv6, opaque hosts), the percent-encode sets, the setters, origins including blob:, and application/x-www-form-urlencoded. A parsed URL is one string and the offsets of its components, written as it's parsed. IDNA is UTS #46 with the URL Standard's options, Punycode, and the RFC 5893 Bidi and RFC 5892 ContextJ rules. NFC and NFD come from the character data and are public as parsec_url::normalize. The tables are generated by scripts/gen-tables.py from Unicode 18.0, the version the pinned WPT IDNA tests come from. Every WPT case passes, so known-failures.txt is gone and the runner fails on any failure. NormalizationTest.txt is vendored and runs in cargo test. url and idna are no longer dependencies of parsec-url; they stay in the lockfile through crates/parsec. Closes #82
scripts/check-headers.sh wants every tracked Rust file to start with the SPDX and copyright lines; gen-tables.py now writes them.
M6 is done: all 4,565 WPT URL cases pass, NormalizationTest passes, and on the 83,113 links in the bench pages Parsec takes 107 ns a URL to Ada's 142 and Lexbor's 243, measured twice at load under 3.
set_userinfo took a bool named password, so CodeQL flagged the true and false passed to it as hard-coded passwords. It now takes a function that picks the username or password part.
# Conflicts: # README.md
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
parsec-urlwrapped theurlandidnacrates. Against WPT at6dac967they pass 3,690 of 4,565 URL cases; 795 of the 875 failures are the June 2026 rule that keeps an ASCII domain as written, and the rest are file: hosts before drive letters, blob: origins, spaces at the end of opaque paths,^in paths and a few more. On the 83,113 links in the bench pages Ada was 1.25 times as fast as Parsec. This is #82.Change
crates/parsec-url, behind the same API, written from the URL Standard's current text: the state machine, host parsing (domains, IPv4 with the ends-in-a-number rule, IPv6, opaque hosts), the percent-encode sets, the setters as the basic URL parser with a state override, origins includingblob:, andapplication/x-www-form-urlencoded.Urlis oneStringand the offsets of its components, written as it's parsed, the way Ada'surl_aggregatoris. Runs that need no encoding are copied whole, and an ASCII host is lowercased in one pass with no IDNA, which since June 2026 is all the standard asks of it.parsec_url::normalize::{nfc, nfd}: decomposition, canonical ordering, composition with the exclusions, Hangul by arithmetic. It's M6's Unicode normalization item.scripts/gen-tables.pywritessrc/tables.rsfrom the Unicode data files, deterministically and rustfmt'd. It uses Unicode 18.0, not 17.0: WPT's IdnaTestV2.json at the pinned commit is generated from 18.0, and seven of its cases use code points 18.0 added.known-failures.txtis gone and the WPT runner fails on any failure.urlandidnaare no longer dependencies ofparsec-url; they stay inCargo.lockthroughcrates/parsec.Url::as_url()and theurl::Urlconversions go with the crate.ParseErrorandHostare this crate's own types, with the same names.domain_to_unicodenow returns a domain with an error unchanged, as the standard's domain to Unicode does.Tests
tests/normalization.rsruns all of Unicode 18.0's NormalizationTest.txt, now vendored with its licence: 20,171 lines checked ten ways each, plus part 1's rule over every scalar value. All pass.cargo run --release --manifest-path bench/Cargo.toml -- urls: two runs at one-minute load under 3. Real links (83,113): Parsec 104 and 107 ns, Ada 141 and 142, Lexbor 239 and 243, so 1.33x Ada and 2.28x Lexbor; all three agree on every href. WPT inputs (904): Parsec 124, Ada 145 and 157, Lexbor 180 and 183; Ada agrees on all 634 that parse, Lexbor differs on 16. Theurlcrate took 181 ns on the real links.hrefthat reparses differently.cargo fmt,cargo clippy --workspace --all-targets -D warnings,cargo test --workspaceandcargo deny checkpass.Closes #82