Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/inlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,8 @@ var parseLinkDestination = function() {
this.pos += 1;
openparens -= 1;
}
} else if (reWhitespaceChar.exec(fromCodePoint(c)) !== null) {
} else if (c <= 0x20 || c === 0x7F) {
// ASCII space or control character (U+0000–1F, U+007F)
break;
} else {
this.pos += 1;
Expand Down
25 changes: 25 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,31 @@ var cases = [
input: "abc\u0000xyz\u0000\n",
expected: "<p>abc\ufffdxyz\ufffd</p>\n"
},
{
name: "Issue #127 U+0001 in unbracketed link destination",
input: "[a](\x01)\n",
expected: "<p>[a](\x01)</p>\n"
},
{
name: "Issue #127 U+007F in unbracketed link destination",
input: "[a](\x7f)\n",
expected: "<p>[a](\x7f)</p>\n"
},
{
name: "Issue #127 control character inside unbracketed link destination",
input: "[a](foo\x07bar)\n",
expected: "<p>[a](foo\x07bar)</p>\n"
},
{
name: "Issue #127 U+0001 in unbracketed image destination",
input: "![a](\x01)\n",
expected: "<p>![a](\x01)</p>\n"
},
{
name: "Issue #127 control character in link reference destination",
input: "[foo]: /url\x01\n\n[foo]\n",
expected: "<p>[foo]: /url\x01</p>\n<p>[foo]</p>\n"
},
{
name: "alternate line endings",
input: "- a\n- b\r- c\r\n- d",
Expand Down