Skip to content

Commit

Permalink
Prevent XSS attack by filtering src attribute on markdown input
Browse files Browse the repository at this point in the history
  • Loading branch information
Herbert Gainor committed Oct 16, 2022
1 parent 6f2e76b commit 3b66f59
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface SafeMarkdownProps {

function isSafeMarkup(node: MarkdownAbstractSyntaxTree) {
return node.type === 'html' && node.value
? /href="(javascript|vbscript|file):.*"/gim.test(node.value) === false
? !/(href|src)="(javascript|vbscript|file):.*"/gim.test(node.value)
: true;
}

Expand Down

0 comments on commit 3b66f59

Please sign in to comment.