Skip to content

fix(markdown): prevent double encoding of GFM autolink URLs - #40

Merged
palmoni5 merged 1 commit into
mainfrom
palmoni5/markdown-autolink-percent-escapes-20261111
Nov 11, 2026
Merged

palmoni5 merged 1 commit into
mainfrom
palmoni5/markdown-autolink-percent-escapes-20261111

Conversation

@palmoni5

@palmoni5 palmoni5 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Bug

GFM extended URL autolinks use Uri.encodeFull on the whole destination, which escapes % itself, so https://example.com/%40foo gets href=".../%2540foo". See dart-lang#2479 and dart-lang#2169.

Change

  • Keep valid %XX escapes and encode only the rest of the destination, as normalizeLinkDestination already does for inline links (CommonMark example 502).
  • Destinations with no % still go straight to Uri.encodeFull.
  • Invalid sequences are still encoded (%zz -> %25zz).
  • Regression cases in test/extensions/autolink_extension.unit.

Otzaria impact

Bare URLs in imported Markdown that already contain percent escapes (e.g. Hebrew Wikipedia links) now link to the right destination.

QA

format/analyze/test pass locally (Dart 3.13). Differential vs main over the spec inputs, all pub-cache README/CHANGELOG files, Hebrew samples and 20k fuzz inputs: the only differences are %25XX -> %XX inside autolink hrefs.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

PR Health

Publish ✔️
Package Version Status Publish tag (post-merge)
package:markdown ⭐ 7.4.1-wip WIP (no publish necessary)
  • 16 already published.
  • 26 WIP (no publish necessary).

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

This check can be disabled by tagging the PR with skip-publish-check.

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check (for example, for non-user-visible changes when the package version is already at -wip).

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
markdown Non-Breaking 7.3.1 7.4.1-wip 7.4.1-wip ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbol Leaking sources

This check can be disabled by tagging the PR with skip-leaking-check.

Unused Dependencies ✔️
Package Status
markdown ✔️ All dependencies utilized correctly.

For details on how to fix these, see dependency_validator.

This check can be disabled by tagging the PR with skip-unused-dependencies-check.

License Headers ✔️
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/html/test/differential_test.dart
pkgs/html/test/dom_parsing_test.dart
pkgs/html/test/mxss_test.dart
pkgs/html/test/noah_ark_clause_limit_test.dart

This check can be disabled by tagging the PR with skip-license-check.

Coverage ✔️
File Coverage
pkgs/markdown/lib/src/inline_syntaxes/autolink_extension_syntax.dart 💚 100 %

This check for test coverage is informational (issues shown here will not fail the PR).

This check can be disabled by tagging the PR with skip-coverage-check.

@palmoni5
palmoni5 force-pushed the palmoni5/markdown-autolink-percent-escapes-20261111 branch from f6466d1 to 3793f0c Compare November 11, 2026 17:04
@palmoni5
palmoni5 force-pushed the palmoni5/markdown-autolink-percent-escapes-20261111 branch from 3793f0c to 5f8df5e Compare November 11, 2026 17:05
@palmoni5
palmoni5 merged commit 3523347 into main Nov 11, 2026
17 checks passed
@palmoni5
palmoni5 deleted the palmoni5/markdown-autolink-percent-escapes-20261111 branch November 11, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant