allow target="_blank" for href

This commit is contained in:
j 2020-10-15 11:40:14 +02:00
parent 009cdd68c3
commit 47fc01742f

View file

@ -55,8 +55,10 @@
{
'name': 'a',
'required': ['href'],
'optional': ['target'],
'validate': {
'href': /^((https?:\/\/|\/|mailto:).*?)/
'href': /^((https?:\/\/|\/|mailto:).*?)/,
'target': /^_blank$/
}
},
{'name': 'br'},
@ -507,6 +509,8 @@
'<a href="http://www.foo.com/">http://www.foo.com/</a>'
> Ox.sanitizeHTML('<a href="http://foo.com" onclick="alert()">foo</a>')
'<a href="http://foo.com">foo</a>'
> Ox.sanitizeHTML('<a href="http://foo.com" target="_blank">foo</a>')
'<a href="http://foo.com" target="_blank">foo</a>'
> Ox.sanitizeHTML('<a href="javascript:alert()">foo</a>')
'&lt;a href="javascript:alert()"&gt;foo&lt;/a&gt;'
> Ox.sanitizeHTML('<a href="foo">foo</a>')