[markdown] Do not double-encode percent-encoded sequences in autolinks - #2480
[markdown] Do not double-encode percent-encoded sequences in autolinks#2480TsubasaYoshida wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request resolves an issue in AutolinkExtensionSyntax where percent-encoded sequences in autolink destinations were being double-encoded. It introduces a helper method _encodeDestination to preserve existing percent-encoded sequences while encoding other characters. Relevant unit tests and a changelog entry have been added. There are no review comments, so I have no feedback to provide.
AutolinkExtensionSyntax built the href with Uri.encodeFull, which escapes '%' itself, so an already percent-encoded destination like https://example.com/%40foo became https://example.com/%2540foo. Preserve pre-existing %XX sequences and only encode the rest, matching how normalizeLinkDestination treats inline link destinations (https://spec.commonmark.org/0.30/#example-502).
744ec1a to
14a25af
Compare
Add version bump since 7.4.0 is intended for publish.
|
@srawlins - is this a similar bug to the other recent fix? |
Fixes #2479
AutolinkExtensionSyntaxbuilt thehrefwithUri.encodeFull, which escapes%itself, so an already percent-encoded destination likehttps://example.com/%40foobecamehttps://example.com/%2540foo.This PR preserves pre-existing
%XXsequences and percent-encodes only the rest, matching hownormalizeLinkDestinationtreats inline link destinations (https://spec.commonmark.org/0.30/#example-502). Note it deliberately does not reusenormalizeLinkDestinationitself, since that would additionally decode HTML character references and change behavior for destinations containing e.g.&.test/extensions/autolink_extension.unit(pre-encoded sequences preserved, non-ASCII characters still encoded, invalid%still escaped to%25)