primefaces - Server side HTML sanitizer/cleanup for JSF -


is there html sanitizer or cleanup methods available in jsf utilities kit or libraries primefaces/omnifaces?

i need sanitize html input user via p:editor , display safe html output using escape="true", following stackexchange style. before displaying html i'm thinking store sanitized input data database, ready safe use escape="true" , xss not danger.

in order achieve that, need standalone html parser. html parsing rather complex , task , responsibility of beyond scope of jsf, primefaces , omnifaces. you're supposed grab 1 of many existing html parsing libraries.

an example jsoup, has separate method particular purpose of sanitizing html against whitelist: jsoup#clean(). example, if want allow basic html without images, use whitelist.basic():

string sanitizedhtml = jsoup.clean(rawhtml, whitelist.basic()); 

a different alternative use specific text formatting syntax, such markdown (which used here). of parsers sanitize html under covers. example pegdown. perhaps meant when said "stackexchange style".

as saving in db, you'd better save both raw , parsed forms in 2 separate text columns. raw form should redisplayed during editing. parsed form should updated in background when raw form has been edited. during display, show parsed form escape="false".

see also:


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -