Skip to content

Commit 80a3adc

Browse files
committed
Fix crash in linkify inline rule on malformed input
1 parent 49ca65b commit 80a3adc

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

Diff for: CHANGELOG.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88

9-
## [13.1.0] - WIP
10-
### Changed
9+
## [13.0.2] - WIP
10+
### Fixed
1111
- Throw an error if 3rd party plugin doesn't increment `line` or `pos` counters
1212
(previously, markdown-it would likely go into infinite loop instead), #847.
13+
- Fixed crash/infinite loop caused by linkify inline rule, #957.
1314

1415
## [13.0.1] - 2022-05-03
1516
### Fixed
@@ -621,7 +622,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
621622
- Renamed presets folder (configs -> presets).
622623

623624

624-
[13.1.0]: https://github.com/markdown-it/markdown-it/compare/13.0.1...13.1.0
625+
[13.0.2]: https://github.com/markdown-it/markdown-it/compare/13.0.1...13.0.2
625626
[13.0.1]: https://github.com/markdown-it/markdown-it/compare/13.0.0...13.0.1
626627
[13.0.0]: https://github.com/markdown-it/markdown-it/compare/12.3.2...13.0.0
627628
[12.3.2]: https://github.com/markdown-it/markdown-it/compare/12.3.1...12.3.2

Diff for: lib/rules_inline/linkify.js

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ module.exports = function linkify(state, silent) {
3131

3232
url = link.url;
3333

34+
// invalid link, but still detected by linkify somehow;
35+
// need to check to prevent infinite loop below
36+
if (url.length <= proto.length) return false;
37+
3438
// disallow '*' at the end of the link (conflicts with emphasis)
3539
url = url.replace(/\*+$/, '');
3640

Diff for: test/fixtures/markdown-it/linkify.txt

+7
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,10 @@ https://www.sell.fi/sites/default/files/elainlaakarilehti/tieteelliset_artikkeli
167167
.
168168
<p><a href="https://www.sell.fi/sites/default/files/elainlaakarilehti/tieteelliset_artikkelit/kahkonen_t._et_al.canine_pancreatitis-_review.pdf">https://www.sell.fi/sites/default/files/elainlaakarilehti/tieteelliset_artikkelit/kahkonen_t._et_al.canine_pancreatitis-_review.pdf</a></p>
169169
.
170+
171+
regression test, invalid link:
172+
.
173+
i.org[x[x][xx: htt://a.b://a
174+
.
175+
<p><a href="http://i.org">i.org</a>[x[x][xx: htt://a.b://a</p>
176+
.

0 commit comments

Comments
 (0)