Skip to content

Commit

Permalink
Stop link title parsing when second ( is found
Browse files Browse the repository at this point in the history
`[](url (xxx())` is no longer a valid link
  • Loading branch information
rlidwka committed Nov 20, 2020
1 parent 1e8aff0 commit b1651b1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions lib/helpers/parse_link_title.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/markdown-it/commonmark_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b1651b1

Please sign in to comment.