修正 issue #41 href默认允许#开头
This commit is contained in:
2
dist/xss.min.js
vendored
2
dist/xss.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -150,12 +150,13 @@ function safeAttrValue (tag, name, value, cssFilter) {
|
||||
|
||||
if (name === 'href' || name === 'src') {
|
||||
// 过滤 href 和 src 属性
|
||||
// 仅允许 http:// | https:// | mailto: | / 开头的地址
|
||||
// 仅允许 http:// | https:// | mailto: | / | # 开头的地址
|
||||
value = _.trim(value);
|
||||
if (value === '#') return '#';
|
||||
if (!(value.substr(0, 7) === 'http://' ||
|
||||
value.substr(0, 8) === 'https://' ||
|
||||
value.substr(0, 7) === 'mailto:' ||
|
||||
value[0] === '#' ||
|
||||
value[0] === '/')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user