Ox.sanitizeHTML: add replaceTags option
This commit is contained in:
parent
092f27ca19
commit
3cdaebadee
1 changed files with 4 additions and 3 deletions
|
@ -40,7 +40,7 @@
|
||||||
img: [
|
img: [
|
||||||
[
|
[
|
||||||
/<img [^<>]*?src="((\/|https?:\/\/).+?)".*?>/gi,
|
/<img [^<>]*?src="((\/|https?:\/\/).+?)".*?>/gi,
|
||||||
'<img src="$1">'
|
'<img src="{1}">'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
rtl: [
|
rtl: [
|
||||||
|
@ -499,9 +499,10 @@
|
||||||
> Ox.sanitizeHTML('<http://foo.com>')
|
> Ox.sanitizeHTML('<http://foo.com>')
|
||||||
'<<a href="http://foo.com">http://foo.com</a>>'
|
'<<a href="http://foo.com">http://foo.com</a>>'
|
||||||
@*/
|
@*/
|
||||||
Ox.sanitizeHTML = function(html, tags) {
|
Ox.sanitizeHTML = function(html, tags, replaceTags) {
|
||||||
var matches = [];
|
var matches = [];
|
||||||
tags = tags || defaultTags;
|
tags = tags || defaultTags;
|
||||||
|
replaceTags = replaceTags || {};
|
||||||
// html = Ox.clean(html); fixme: can this be a parameter?
|
// html = Ox.clean(html); fixme: can this be a parameter?
|
||||||
if (tags.indexOf('[]') > -1) {
|
if (tags.indexOf('[]') > -1) {
|
||||||
html = html.replace(
|
html = html.replace(
|
||||||
|
@ -513,7 +514,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
tags.forEach(function(tag) {
|
tags.forEach(function(tag) {
|
||||||
var array = replace[tag] || replace['*'](tag);
|
var array = replaceTags[tag] || replace[tag] || replace['*'](tag);
|
||||||
Ox.forEach(array, function(value) {
|
Ox.forEach(array, function(value) {
|
||||||
html = html.replace(value[0], function() {
|
html = html.replace(value[0], function() {
|
||||||
matches.push(Ox.formatString(value[1], arguments));
|
matches.push(Ox.formatString(value[1], arguments));
|
||||||
|
|
Loading…
Reference in a new issue