Skip to content

fix(linkify): strip trailing quotes from auto-linked URLs#552

Open
Yanhu007 wants to merge 1 commit intoyuin:masterfrom
Yanhu007:fix/linkify-strip-trailing-quotes
Open

fix(linkify): strip trailing quotes from auto-linked URLs#552
Yanhu007 wants to merge 1 commit intoyuin:masterfrom
Yanhu007:fix/linkify-strip-trailing-quotes

Conversation

@Yanhu007
Copy link
Copy Markdown

Fixes #335

Problem

When both linkify and typographer extensions are enabled, a quoted URL like "https://example.org/" produces a broken href:

<!-- Expected -->
<p>&ldquo;<a href="https://example.org/">https://example.org/</a>&rdquo;</p>

<!-- Actual (before fix) -->
<p>&ldquo;<a href="https://example.org/%22">https://example.org/&quot;</a></p>

The linkify parser includes the trailing " as part of the URL. The typographer extension converts the opening " to &ldquo; but the closing " is already inside the URL, resulting in %22 in 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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bad href attribute when linkify and typographer extensions are enabled

1 participant