Skip to content

Commit

Permalink
Stop link parsing when second < is found
Browse files Browse the repository at this point in the history
`[](<foo<bar>)` is no longer a valid link
  • Loading branch information
rlidwka committed Nov 19, 2020
1 parent 725a916 commit fa4dc22
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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
- `[](<foo<bar>)` 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.
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/helpers/parse_link_destination.js
Expand Up @@ -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));
Expand Down
12 changes: 12 additions & 0 deletions test/fixtures/markdown-it/commonmark_extras.txt
Expand Up @@ -255,6 +255,18 @@ List item terminating quote should not be paragraph continuation
</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.
.
a
Expand Down

0 comments on commit fa4dc22

Please sign in to comment.