From fa4dc2268039c52e3684d8017512ae9f26a6e980 Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Thu, 19 Nov 2020 23:35:35 +0300 Subject: [PATCH] Stop link parsing when second `<` is found `[]()` is no longer a valid link --- CHANGELOG.md | 6 ++++++ lib/helpers/parse_link_destination.js | 1 + test/fixtures/markdown-it/commonmark_extras.txt | 12 ++++++++++++ 3 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2ef43efb..4c36e4d29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [12.0.3] - WIP +### Fixed +- `[]()` is no longer a valid link. + + ## [12.0.2] - 2020-10-23 ### Fixed - Three pipes (`|\n|\n|`) are no longer rendered as a table with no columns, #724. @@ -534,6 +539,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Renamed presets folder (configs -> presets). +[12.0.3]: https://github.com/markdown-it/markdown-it/compare/12.0.2...12.0.3 [12.0.2]: https://github.com/markdown-it/markdown-it/compare/12.0.1...12.0.2 [12.0.1]: https://github.com/markdown-it/markdown-it/compare/12.0.0...12.0.1 [12.0.0]: https://github.com/markdown-it/markdown-it/compare/11.0.1...12.0.0 diff --git a/lib/helpers/parse_link_destination.js b/lib/helpers/parse_link_destination.js index 10953b645..f85b4f69c 100644 --- a/lib/helpers/parse_link_destination.js +++ b/lib/helpers/parse_link_destination.js @@ -22,6 +22,7 @@ module.exports = function parseLinkDestination(str, pos, max) { while (pos < max) { code = str.charCodeAt(pos); if (code === 0x0A /* \n */) { return result; } + if (code === 0x3C /* < */) { return result; } if (code === 0x3E /* > */) { result.pos = pos + 1; result.str = unescapeAll(str.slice(start + 1, pos)); diff --git a/test/fixtures/markdown-it/commonmark_extras.txt b/test/fixtures/markdown-it/commonmark_extras.txt index 4cda25712..d82d8d50f 100644 --- a/test/fixtures/markdown-it/commonmark_extras.txt +++ b/test/fixtures/markdown-it/commonmark_extras.txt @@ -255,6 +255,18 @@ List item terminating quote should not be paragraph continuation . + +Link destination cannot contain '<' +. +[]() + +[]() +. +

[](<foo)

+

+. + + Coverage. Directive can terminate paragraph. . a