reorder regexp, add test
This commit is contained in:
parent
cc29f8f832
commit
ccae6e4997
1 changed files with 5 additions and 3 deletions
|
@ -49,7 +49,7 @@
|
|||
tag: {
|
||||
a: [
|
||||
[
|
||||
/<a [^<>]*?href="((https?:\/\/|mailto:|\/).+?)".*?>/gi,
|
||||
/<a [^<>]*?href="((\/|https?:\/\/|mailto:).+?)".*?>/gi,
|
||||
'<a href="{1}">',
|
||||
],
|
||||
[
|
||||
|
@ -59,7 +59,7 @@
|
|||
],
|
||||
img: [
|
||||
[
|
||||
/<img [^<>]*?src="((https?:\/\/|\/).+?)".*?>/gi,
|
||||
/<img [^<>]*?src="((\/|https?:\/\/).+?)".*?>/gi,
|
||||
'<img src="$1">'
|
||||
]
|
||||
],
|
||||
|
@ -347,6 +347,8 @@
|
|||
'<a href="http://foo.com">foo</a>'
|
||||
> Ox.sanitizeHTML('<a href="javascript:alert()">foo</a>')
|
||||
'<a href="javascript:alert()">foo'
|
||||
> Ox.sanitizeHTML('<a href="/foo">foo</a>')
|
||||
'<a href="/foo">foo</a>'
|
||||
> Ox.sanitizeHTML('[http://foo.com foo]')
|
||||
'<a href="http://foo.com">foo</a>'
|
||||
> Ox.sanitizeHTML('<rtl>foo</rtl>')
|
||||
|
@ -365,7 +367,7 @@
|
|||
tags = tags || defaultTags;
|
||||
// html = Ox.clean(html); fixme: can this be a parameter?
|
||||
if (tags.indexOf('[]') > -1) {
|
||||
html = html.replace(/\[((https?:\/\/|mailto:|\/).+?) (.+?)\]/gi, '<a href="$1">$3</a>');
|
||||
html = html.replace(/\[((\/|https?:\/\/|mailto:).+?) (.+?)\]/gi, '<a href="$1">$3</a>');
|
||||
tags = tags.filter(function(tag) {
|
||||
return tag != '[]';
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue