Repository navigation
🐛 fix(url): judge strict language subdomain on canonical host - #2273
Merged
Merged
Conversation
The strict language filter took its subdomain label from the host as spelled in the URL, before percent-decoding, IDNA mapping and lowercasing. A browser resolves those spellings to another label, so spellings of one host could get different decisions. The cleaner now canonicalizes the host once and uses that host for both the language check and the output, so every spelling gets the same decision. Fixes tox-dev#2244
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.
The strict language filter in
clean_url()andextract_links()decided on the subdomain label of a host as the URL spelled it (clean()before the fix, strict label check). Two spellings of one host could get different decisions, and a decision could follow a label that a browser never opens, so the links a crawler keeps depended on how the host was written. 🔗 Now every spelling of a host gets the same decision, based on the host a browser opens. Fixes #2244.The label came from the spelled host
The URL host parser percent-decodes the host, maps it to ASCII with UTS #46 and lowercases it before a browser opens it. The old code lowercased the spelled host and passed it to the strict check, which reads the label before the first dot. That label was taken before the decoding and mapping steps ran.
One canonical host decides and is emitted
canonical_host()runs the checked host parser that the output already used, andclean()computes it once per web URL. The language check andnormalize_parts()both take that host, so the label that decides a URL and the host written to the output come from one computation. A host that does not canonicalize is not fetchable and is dropped, as before. The strict label check inurl.cis unchanged and now receives the canonical host.Behavior changes
strict=Trueand alanguage, a link is judged on the subdomain label of its canonical host. A link whose spelled host had a different label can now be kept or dropped where it was not before.strict, the language check reads no host label, so its result does not change.