Skip to content

Commit e629800

Browse files
committed
Fix XSS vulnerability in link regex [Security Issue]
1 parent 0f3b028 commit e629800

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

public/js/render.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// allow some attributes
44
var whiteListAttr = ['id', 'class', 'style']
55
window.whiteListAttr = whiteListAttr
6-
// allow link starts with '.', '/' and custom protocol with '://'
7-
var linkRegex = /^([\w|-]+:\/\/)|^([.|/])+/
6+
// allow link starts with '.', '/' and custom protocol with '://', exclude link starts with javascript://
7+
var linkRegex = /^(?!javascript:\/\/)([\w|-]+:\/\/)|^([.|/])+/
88
// allow data uri, from https://gist.github.com/bgrins/6194623
99
var dataUriRegex = /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@/?%\s]*)\s*$/i
1010
// custom white list

0 commit comments

Comments
 (0)