R
R
recloudor2015-11-22 14:59:02
JavaScript
recloudor, 2015-11-22 14:59:02

How to change regExp, add whiteAttr?

String.prototype.sanitizeHTML=function (white,black) {
   if (!white) white="b|i|p|br";
   if (!black) black="script|object|embed";
   var e=new RegExp("(<("+black+")[^>]*>.*</\\2>|(?!<[/]?("+white+")(\\s[^<]*>|[/]>|>))<[^<>]*>|(?!<[^<>\\s]+)\\s[^</>]+(?=[/>]))", "gi");
   return this.replace(e,"");
}

It is necessary to add a list of allowed attributes, so that they are not deleted, tell me how to change regExp?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question