Browse Source

Stop link title parsing when second `(` is found

`[](url (xxx())` is no longer a valid link
pull/745/head
Alex Kocharin 4 years ago
parent
commit
b1651b1363
  1. 1
      CHANGELOG.md
  2. 2
      lib/helpers/parse_link_title.js
  3. 11
      test/fixtures/markdown-it/commonmark_extras.txt

1
CHANGELOG.md

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [12.0.3] - WIP
### Fixed
- `[](<foo<bar>)` is no longer a valid link.
- `[](url (xxx())` is no longer a valid link.
- Fix performance issues when parsing links, #732.
- Fix performance issues when parsing backticks, #733.

2
lib/helpers/parse_link_title.js

@ -37,6 +37,8 @@ module.exports = function parseLinkTitle(str, pos, max) {
result.str = unescapeAll(str.slice(start + 1, pos));
result.ok = true;
return result;
} else if (code === 0x28 /* ( */ && marker === 0x29 /* ) */) {
return result;
} else if (code === 0x0A) {
lines++;
} else if (code === 0x5C /* \ */ && pos + 1 < max) {

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

@ -267,6 +267,17 @@ Link destination cannot contain '<'
.
Link title cannot contain '(' when opened with it
.
[](url (xxx())
[](url (xxx\())
.
<p>[](url (xxx())</p>
<p><a href="url" title="xxx("></a></p>
.
Coverage. Directive can terminate paragraph.
.
a

Loading…
Cancel
Save