dimanche 31 janvier 2016

Handle Html tags in input area

Need to allow/disallow some certain html tags in js side. Developing a laravel project where in some input box need to consider certain html elements.

Can be done using string replace function but will take much more time to maintain the list of not allowable items.like the following

function escapeHtml(unsafe) {
    return unsafe
         .replace(/&/g, "&")
         .replace(/</g, "&lt;")
         .replace(/>/g, "&gt;")
         .replace(/"/g, "&quot;")
         .replace(/'/g, "&#039;");
 }

Again the allowed html tag list can also be small so if just want to allow
then the unsafe list will be huge.

I can also do it in server side but cant get any proper source for that.

It will be so helpful if someone can just suggest me what would be the best way for maintaining this allow/disallow html tag list?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire