Repository navigation
🐛 Match linkify schemes as ASCII only - #493
Open
shashank11yadav wants to merge 1 commit into
Open
shashank11yadav wants to merge 1 commit into
shashank11yadav wants to merge 1 commit into
Conversation
With re.IGNORECASE on a str pattern, [a-z] also matches U+017F (long s) and U+212A (Kelvin sign), so a bare URL right after either character was read as part of the scheme and left unlinked. Add re.ASCII so the scheme follows RFC 3986, where ALPHA is ASCII only.
|
This branch has not been deployed
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.
With linkify enabled, a bare URL that comes right after
ſ(U+017F, LATIN SMALL LETTER LONG S) orK(U+212A, KELVIN SIGN) is not linkified. The same URL afteréor!is.SCHEME_REinmarkdown_it/rules_inline/linkify.pyis compiled withre.IGNORECASEon astrpattern, so Python uses Unicode case folding.[a-z]then also matches these two characters, the captured scheme becomesſhttp/Khttp, and linkify-it rejects it. Addingre.ASCIIlimits the scheme to ASCII letters, as the RFC 3986 comment above the regex already says.rules_block/html_block.pyuses the same ASCII-only approach for its case-insensitive patterns.Open PR #485 replaces
SCHEME_REwith an ASCII-only backscan, so it would also cover this case. The new test applies to either change.Fixes #492
How it was tested:
test_linkify_scheme_is_ascii_onlyintests/test_linkify.py, parametrized over U+017F and U+212A. Both cases fail without the fix and pass with it.pytest tests: 1192 passed.ruff check .,ruff format --check .(ruff 0.17.4) andmypy --ignore-missing-imports markdown_it tests(mypy 2.4.1) pass. These are the versions pinned in.pre-commit-config.yaml.pre-commit run --all-filesitself was not run, so thepre-commit-hookschecks (whitespace, end-of-file, JSON/YAML) were not run.