Skip to content

Commit

Permalink
fix: disallow ascii control characters in URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
dominykas committed May 14, 2019
1 parent 1c5b5b7 commit 5f17c48
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/helpers/parse_link_destination.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ module.exports = function parseLinkDestination(state, pos) {

if (code === 0x20) { break; }

if (code > 0x08 && code < 0x0e) { break; }
// ascii control chars
if (code < 0x20 || code === 0x7F) { break; }

if (code === 0x5C /* \ */ && pos + 1 < max) {
pos += 2;
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/remarkable/xss.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,12 @@ javascript:alert(1)
<p>javascript:alert(1)</p>
<p>javascript:alert(1)</p>
.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 82

.
[ASCII control characters XSS](javascript:alert(1))
.
<p>[ASCII control characters XSS](javascript:alert(1))</p>
.

0 comments on commit 5f17c48

Please sign in to comment.