Repository navigation
🐛 fix(extract): read meta refresh like browsers - #2126
Merged
Merged
Conversation
links() and Document.meta_refresh() read a <meta http-equiv=refresh> target differently. The link scanner searched the whole content value for a url= keyword, so a keyword inside the target was taken as the target. meta_refresh() stopped at a delay with no separator and kept text after the delay that a browser never follows. Both readers now call one routine in core/refresh.h that follows the HTML shared declarative refresh steps, so every reader names the URL a browser redirects to. Text right after the delay that is not a separator is no refresh, so meta_refresh() returns None for it. A lone "." delay now reads as zero instead of raising ValueError. Fixes tox-dev#1737
Merging this PR will not alter performance
Comparing Footnotes
|
The CSS scanner checks the byte before url( with the identifier test. Prefixes that are an uppercase letter, a digit, or punctuation had no case, so those branches of the check never ran on the 3.14 coverage gate.
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 link methods and
Document.meta_refresh()read the same<meta http-equiv=refresh>value differently. One tag could name different targets depending on the method, so a crawler, link checker or rewriter could list or rewrite a target that a browser does not follow, or miss the one it does. 🔗 After this change all of them read the value by the HTML standard's pragma directive rules, so they agree with each other and with browsers.Architecture
One routine reads the delay and the target from the value, and both the link scanner and
Document.meta_refresh()call it. The routine sits in the core layer, next to the ASCII helpers, because the extract and DOM modules both need it and neither should own the other's parsing. The HTML standard reads the target only after the delay and a separator, and theurl=keyword is optional and counts only at that position.Behavior changes
Document.meta_refresh()returnsNonefor a value with text other than a separator right after the delay. It returned that text as the redirect before.Document.meta_refresh()treats whitespace alone as the separator and returns the target after it.links(),rewrite_links()andresolve_links()report no link for a value without a delay. The old scanner reported anyurl=target in the value.links(),rewrite_links()andresolve_links()report a target written withouturl=, and take an unquoted target to the end of the value instead of its first space.url=keyword counts only right after the delay. An unquoted target runs to the end of the value, with surrounding whitespace removed. A quoted target with no closing quote runs to the end of the value, and the quote is no longer part of the target.Document.meta_refresh()returns the fallback URL..makesDocument.meta_refresh()return a delay of0.0with the fallback URL. It raisedValueErrorbefore.Fixes #1737.