Skip to content

Commit

Permalink
fix: disallow ascii control characters in URLs (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominykas authored and TrySound committed Jul 27, 2019
1 parent 4ad13a0 commit 92d79a9
Show file tree
Hide file tree
Showing 2 changed files with 9 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
7 changes: 7 additions & 0 deletions test/fixtures/remarkable/xss.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,10 @@ javascript:alert(1)
<p>javascript:alert(1)</p>
<p>javascript:alert(1)</p>
.


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

0 comments on commit 92d79a9

Please sign in to comment.