fix(linkify): strip trailing quotes from auto-linked URLs#552
Open
Yanhu007 wants to merge 1 commit intoyuin:masterfrom
Open
fix(linkify): strip trailing quotes from auto-linked URLs#552Yanhu007 wants to merge 1 commit intoyuin:masterfrom
Yanhu007 wants to merge 1 commit intoyuin:masterfrom
Conversation
The linkify parser trims trailing punctuation (., ), ;) from
auto-detected URLs but does not handle quote characters. When
combined with the typographer extension, a URL like:
"https://example.org/"
produces a broken href with the closing quote encoded as %22,
because linkify includes it in the URL before typographer can
convert it to a smart quote.
Strip trailing double and single quotes from auto-linked URLs,
matching the existing behavior for other trailing punctuation.
Fixes yuin#335
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.
Fixes #335
Problem
When both linkify and typographer extensions are enabled, a quoted URL like
"https://example.org/"produces a broken href:The linkify parser includes the trailing
"as part of the URL. The typographer extension converts the opening"to“but the closing"is already inside the URL, resulting in%22in the href.Fix
Add
"and'to the trailing punctuation characters that linkify strips from auto-detected URLs, matching the existing behavior for.,), and;(HTML entities).Testing
All existing tests pass. The fix is a 2-line addition to the existing trailing-character trimming logic.