Browse Source

Stop link parsing when second `<` is found

`[](<foo<bar>)` is no longer a valid link
pull/745/head
Alex Kocharin 4 years ago
parent
commit
f688abccaf
  1. 6
      CHANGELOG.md
  2. 1
      lib/helpers/parse_link_destination.js
  3. 12
      test/fixtures/markdown-it/commonmark_extras.txt

6
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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [12.0.3] - WIP
### Fixed
- `[](<foo<bar>)` is no longer a valid link.
## [12.0.2] - 2020-10-23 ## [12.0.2] - 2020-10-23
### Fixed ### Fixed
- Three pipes (`|\n|\n|`) are no longer rendered as a table with no columns, #724. - 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). - 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.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.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 [12.0.0]: https://github.com/markdown-it/markdown-it/compare/11.0.1...12.0.0

1
lib/helpers/parse_link_destination.js

@ -22,6 +22,7 @@ module.exports = function parseLinkDestination(str, pos, max) {
while (pos < max) { while (pos < max) {
code = str.charCodeAt(pos); code = str.charCodeAt(pos);
if (code === 0x0A /* \n */) { return result; } if (code === 0x0A /* \n */) { return result; }
if (code === 0x3C /* < */) { return result; }
if (code === 0x3E /* > */) { if (code === 0x3E /* > */) {
result.pos = pos + 1; result.pos = pos + 1;
result.str = unescapeAll(str.slice(start + 1, pos)); result.str = unescapeAll(str.slice(start + 1, pos));

12
test/fixtures/markdown-it/commonmark_extras.txt

@ -255,6 +255,18 @@ List item terminating quote should not be paragraph continuation
</ol> </ol>
. .
Link destination cannot contain '<'
.
[](<foo<bar>)
[](<foo\<bar>)
.
<p>[](&lt;foo<bar>)</p>
<p><a href="foo%3Cbar"></a></p>
.
Coverage. Directive can terminate paragraph. Coverage. Directive can terminate paragraph.
. .
a a

Loading…
Cancel
Save