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 Jul 26, 2019
1 parent 4ad13a0 commit 80200e3
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 @@ -49,7 +49,8 @@ export default 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 80200e3

Please sign in to comment.