SafeUri can not be used as SafeHtml??

202 views
Skip to first unread message

Patrick Tucker

unread,
Apr 23, 2012, 1:25:59 PM4/23/12
to google-we...@googlegroups.com
We have a template that we are converting to using SafeHtml and SafeUri, but ran into a problem.
 
The template looks something like this:
<a href="{0}" ...>{0}</a>
 
Argument 0 is the URL, if we change the value from String to SafeUri we get the following error:
[ERROR] SafeUri can only be used as the entire value of a URL attribute. Did you mean to use java.lang.String or SafeHtml instead?
 
The only way around this is to keep the argument a String or add another argument that is a SafeHtml of the URL.  Neither of these options seems ideal to me.
 
Thoughts?  I don't see any reason why a valid URL can not be considered SafeHtml?

Thomas Broyer

unread,
Apr 23, 2012, 3:22:04 PM4/23/12
to google-we...@googlegroups.com
John thought that using SafeUri outside a URL attribute would likely be a dev mistake; so the solution really is to add another argument to your SafeHtmlTemplates method. 

Patrick Tucker

unread,
Apr 23, 2012, 4:43:50 PM4/23/12
to google-we...@googlegroups.com
Well that stinks.  Seems like a warning would suffice, allowing those that did it on purpose to be able to do it and those who did it on accident to fix it.
Is there somethinng that can be done to allow us to do this?   Maybe another class that is both a SafeHtml and SafeUri that can be used in both places?

Thomas Broyer

unread,
Apr 23, 2012, 8:49:08 PM4/23/12
to google-we...@googlegroups.com


On Monday, April 23, 2012 10:43:50 PM UTC+2, Patrick Tucker wrote:
Well that stinks.  Seems like a warning would suffice, allowing those that did it on purpose to be able to do it and those who did it on accident to fix it.
Is there somethinng that can be done to allow us to do this?   Maybe another class that is both a SafeHtml and SafeUri that can be used in both places?

Well, I suppose we can bring the discussion to GWT-Contributors and see if John is OK to change it to a warning in retrospect. 

Patrick Tucker

unread,
Apr 24, 2012, 8:25:37 AM4/24/12
to google-we...@googlegroups.com
I don't want to make a big fuss about it, I just thought it was odd that GWT would restrict something that is valid and I thought was common.
Reply all
Reply to author
Forward
0 new messages