You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ted <r6...@gmail.com> on 2011/10/19 05:36:00 UTC

is i18n messages suppose to be html escaped?

I'm using string tables and to i18n some messages using jsf and I've got
some unexpected behavior

if I have a string table

string1=<bold>asdf</bold>
string2=my "cow" is brown

if I then go on to a jsf page and do

#{msg.string1}
#{msg.string2}

the result I get is

&lt;bold&gt;asdf&lt;/bold&gt;
my "cow" is brown

My expectation is that the quote should have been converted to &quot;
shouldn't it? (either that or at least the <'s should not have been
escaped...)

anyone know anything about this?
-- 
Ted.

Re: is i18n messages suppose to be html escaped?

Posted by Mike Kienenberger <mk...@gmail.com>.
I don't know about the escaping, but "#(msg.foo} is a shortcut for
outputText" is only true functionally, and then only in the generic
sense that both will put text on the page.  Ie, #{msg.foo} will
evaluate to a literal piece of text, but it is not the same thing as
using an outputText component.

It would be the same kind of thing as saying that
"System.error.println(foo)" is a shortcut to "log.debug(foo)"

On Wed, Oct 19, 2011 at 5:08 AM, Ted <r6...@gmail.com> wrote:
> oh and in addition to the inconsistency between the 2 example strings, I
> just checked, to the best of my knowledge #{msg.foo} is a short cut for
> outputText tag,
>
> The outputText tag, according to the jsf javadocs, says it is "true" by
> default.
>
> So, if that's true, shouldn't " be escaped to &quot; by default? or are "
> special for some reason?
>
> On Wed, Oct 19, 2011 at 8:02 PM, Ted <r6...@gmail.com> wrote:
>
>> thanks, but I posted 2 strings, one was escaped while the other was not.
>> Shouldn't it at least consistently escape or not escape?
>>
>>
>> On Wed, Oct 19, 2011 at 4:11 PM, Kito Mann <ki...@virtua.com> wrote:
>>
>>> Ted,
>>>
>>> The strings will only be escaped if the component you're using escapes the
>>> text. If you're just embedding the expression in the page, it's not going
>>> to
>>> be escaped, but you can use <h:outputText> -- this allows you to control
>>> whether or not you want the text escaped.
>>> ---
>>> Kito D. Mann | twitter: kito99 | Author, JSF in Action
>>> Virtua, Inc. | http://www.virtua.com | JSF/Java EE training and
>>> consulting
>>> http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info |
>>> twitter:
>>> jsfcentral
>>> +1 203-404-4848 x3
>>>
>>> * Listen to the latest headlines in the JSF and Java EE newscast:
>>>
>>> http://blogs.jsfcentral.com/roller/editorsdesk/category/JSF+and+Java+EE+Newscast
>>> * Keep up with the aftermath of the Oracle/Sun merger:
>>> http://www.mergerspeak.com
>>>
>>>
>>>
>>> On Tue, Oct 18, 2011 at 11:36 PM, Ted <r6...@gmail.com> wrote:
>>>
>>> > I'm using string tables and to i18n some messages using jsf and I've got
>>> > some unexpected behavior
>>> >
>>> > if I have a string table
>>> >
>>> > string1=<bold>asdf</bold>
>>> > string2=my "cow" is brown
>>> >
>>> > if I then go on to a jsf page and do
>>> >
>>> > #{msg.string1}
>>> > #{msg.string2}
>>> >
>>> > the result I get is
>>> >
>>> > &lt;bold&gt;asdf&lt;/bold&gt;
>>> > my "cow" is brown
>>> >
>>> > My expectation is that the quote should have been converted to &quot;
>>> > shouldn't it? (either that or at least the <'s should not have been
>>> > escaped...)
>>> >
>>> > anyone know anything about this?
>>> > --
>>> > Ted.
>>> >
>>>
>>
>>
>>
>> --
>> Ted.
>>
>>
>
>
> --
> Ted.
>

Re: is i18n messages suppose to be html escaped?

Posted by Ted <r6...@gmail.com>.
oh and in addition to the inconsistency between the 2 example strings, I
just checked, to the best of my knowledge #{msg.foo} is a short cut for
outputText tag,

The outputText tag, according to the jsf javadocs, says it is "true" by
default.

So, if that's true, shouldn't " be escaped to &quot; by default? or are "
special for some reason?

On Wed, Oct 19, 2011 at 8:02 PM, Ted <r6...@gmail.com> wrote:

> thanks, but I posted 2 strings, one was escaped while the other was not.
> Shouldn't it at least consistently escape or not escape?
>
>
> On Wed, Oct 19, 2011 at 4:11 PM, Kito Mann <ki...@virtua.com> wrote:
>
>> Ted,
>>
>> The strings will only be escaped if the component you're using escapes the
>> text. If you're just embedding the expression in the page, it's not going
>> to
>> be escaped, but you can use <h:outputText> -- this allows you to control
>> whether or not you want the text escaped.
>> ---
>> Kito D. Mann | twitter: kito99 | Author, JSF in Action
>> Virtua, Inc. | http://www.virtua.com | JSF/Java EE training and
>> consulting
>> http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info |
>> twitter:
>> jsfcentral
>> +1 203-404-4848 x3
>>
>> * Listen to the latest headlines in the JSF and Java EE newscast:
>>
>> http://blogs.jsfcentral.com/roller/editorsdesk/category/JSF+and+Java+EE+Newscast
>> * Keep up with the aftermath of the Oracle/Sun merger:
>> http://www.mergerspeak.com
>>
>>
>>
>> On Tue, Oct 18, 2011 at 11:36 PM, Ted <r6...@gmail.com> wrote:
>>
>> > I'm using string tables and to i18n some messages using jsf and I've got
>> > some unexpected behavior
>> >
>> > if I have a string table
>> >
>> > string1=<bold>asdf</bold>
>> > string2=my "cow" is brown
>> >
>> > if I then go on to a jsf page and do
>> >
>> > #{msg.string1}
>> > #{msg.string2}
>> >
>> > the result I get is
>> >
>> > &lt;bold&gt;asdf&lt;/bold&gt;
>> > my "cow" is brown
>> >
>> > My expectation is that the quote should have been converted to &quot;
>> > shouldn't it? (either that or at least the <'s should not have been
>> > escaped...)
>> >
>> > anyone know anything about this?
>> > --
>> > Ted.
>> >
>>
>
>
>
> --
> Ted.
>
>


-- 
Ted.

Re: is i18n messages suppose to be html escaped?

Posted by Ted <r6...@gmail.com>.
thanks, but I posted 2 strings, one was escaped while the other was not.
Shouldn't it at least consistently escape or not escape?

On Wed, Oct 19, 2011 at 4:11 PM, Kito Mann <ki...@virtua.com> wrote:

> Ted,
>
> The strings will only be escaped if the component you're using escapes the
> text. If you're just embedding the expression in the page, it's not going
> to
> be escaped, but you can use <h:outputText> -- this allows you to control
> whether or not you want the text escaped.
> ---
> Kito D. Mann | twitter: kito99 | Author, JSF in Action
> Virtua, Inc. | http://www.virtua.com | JSF/Java EE training and consulting
> http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info |
> twitter:
> jsfcentral
> +1 203-404-4848 x3
>
> * Listen to the latest headlines in the JSF and Java EE newscast:
>
> http://blogs.jsfcentral.com/roller/editorsdesk/category/JSF+and+Java+EE+Newscast
> * Keep up with the aftermath of the Oracle/Sun merger:
> http://www.mergerspeak.com
>
>
>
> On Tue, Oct 18, 2011 at 11:36 PM, Ted <r6...@gmail.com> wrote:
>
> > I'm using string tables and to i18n some messages using jsf and I've got
> > some unexpected behavior
> >
> > if I have a string table
> >
> > string1=<bold>asdf</bold>
> > string2=my "cow" is brown
> >
> > if I then go on to a jsf page and do
> >
> > #{msg.string1}
> > #{msg.string2}
> >
> > the result I get is
> >
> > &lt;bold&gt;asdf&lt;/bold&gt;
> > my "cow" is brown
> >
> > My expectation is that the quote should have been converted to &quot;
> > shouldn't it? (either that or at least the <'s should not have been
> > escaped...)
> >
> > anyone know anything about this?
> > --
> > Ted.
> >
>



-- 
Ted.

Re: is i18n messages suppose to be html escaped?

Posted by Kito Mann <ki...@virtua.com>.
Ted,

The strings will only be escaped if the component you're using escapes the
text. If you're just embedding the expression in the page, it's not going to
be escaped, but you can use <h:outputText> -- this allows you to control
whether or not you want the text escaped.
---
Kito D. Mann | twitter: kito99 | Author, JSF in Action
Virtua, Inc. | http://www.virtua.com | JSF/Java EE training and consulting
http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info | twitter:
jsfcentral
+1 203-404-4848 x3

* Listen to the latest headlines in the JSF and Java EE newscast:
http://blogs.jsfcentral.com/roller/editorsdesk/category/JSF+and+Java+EE+Newscast
* Keep up with the aftermath of the Oracle/Sun merger:
http://www.mergerspeak.com



On Tue, Oct 18, 2011 at 11:36 PM, Ted <r6...@gmail.com> wrote:

> I'm using string tables and to i18n some messages using jsf and I've got
> some unexpected behavior
>
> if I have a string table
>
> string1=<bold>asdf</bold>
> string2=my "cow" is brown
>
> if I then go on to a jsf page and do
>
> #{msg.string1}
> #{msg.string2}
>
> the result I get is
>
> &lt;bold&gt;asdf&lt;/bold&gt;
> my "cow" is brown
>
> My expectation is that the quote should have been converted to &quot;
> shouldn't it? (either that or at least the <'s should not have been
> escaped...)
>
> anyone know anything about this?
> --
> Ted.
>