Sunday, May 5, 2013

Modifying SimpleHtmlSanitizer.java, how to deal with <a href=> (Gwt)?

You know that SimpleHtmlSanitizer.java only accepts the following markup ("b", "em", "i", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "ul", "ol", "li"). It is good but I want "u", "sub", "a href=" & don't want "hr", "ul", "ol", "li". So I need to modify this class.

Now look at the SimpleHtmlSanitizer.java (https://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/safehtml/shared/SimpleHtmlSanitizer.java?r=8653) & look at this line in that class:

Arrays.asList("b", "em", "i", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "ul", "ol", "li"));

You can guess that we can put our wished list into that line of code right. So I modify it to:

Arrays.asList("b","i", "u", "h1", "h2", "h3", "h4","a href="));

Every tag in that list works fine except the "a href=". For example, when i put the string Test <a href="car.com"><hr>hello</a> it didn't show correct output. The correct output should have string <hr>hello in hyperlink.

I believed that we have to use modify simpleSanitize function in SimpleHtmlSanitizer class, we also have to use UriUtils.isSafeUri to check if the uri is safe or not.

So how to modify SimpleHtmlSanitizer in the case of<a href=

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate