Browse Source

Disallow escaped spaces inside link destination

pull/745/head
Alex Kocharin 4 years ago
parent
commit
2290e109c5
  1. 1
      CHANGELOG.md
  2. 1
      lib/helpers/parse_link_destination.js
  3. 8
      test/fixtures/markdown-it/commonmark_extras.txt

1
CHANGELOG.md

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

1
lib/helpers/parse_link_destination.js

@ -53,6 +53,7 @@ module.exports = function parseLinkDestination(str, pos, max) {
if (code < 0x20 || code === 0x7F) { break; } if (code < 0x20 || code === 0x7F) { break; }
if (code === 0x5C /* \ */ && pos + 1 < max) { if (code === 0x5C /* \ */ && pos + 1 < max) {
if (str.charCodeAt(pos + 1) === 0x20) { break; }
pos += 2; pos += 2;
continue; continue;
} }

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

@ -278,6 +278,14 @@ Link title cannot contain '(' when opened with it
. .
Escaped space is not allowed in link destination, commonmark/CommonMark#493.
.
[link](a\ b)
.
<p>[link](a\ b)</p>
.
Coverage. Directive can terminate paragraph. Coverage. Directive can terminate paragraph.
. .
a a

Loading…
Cancel
Save