HTML tags in properties file

2,875 views
Skip to first unread message

atta ur rehman

unread,
Aug 8, 2011, 7:00:23 AM8/8/11
to lif...@googlegroups.com
Hi all,

We're using properties file for i18n and there is a line that need to show ® (&reg;) and TM (<sup>TM</sup>) symbols. Now I've tried both &reg; and <sup>TM</sup> in the properties file but on the page they come up as it is. That's they are being escaped. 

Any ideas on how to handle this situation in properties files. 

Thanks. 

ATTA

Tyler Weir

unread,
Aug 8, 2011, 10:49:52 AM8/8/11
to lif...@googlegroups.com
Check this out (stolen from StackOverflow, since this is a java question)

atta ur rehman

unread,
Aug 8, 2011, 11:14:21 AM8/8/11
to lif...@googlegroups.com
Thanks, Tyler, it worked! 

ATTA

On Mon, Aug 8, 2011 at 3:49 PM, Tyler Weir <tyler...@gmail.com> wrote:
Check this out (stolen from StackOverflow, since this is a java question)

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To view this discussion on the web visit https://groups.google.com/d/msg/liftweb/-/kxrOCcD6hQkJ.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.

Tyler Weir

unread,
Aug 8, 2011, 11:28:47 AM8/8/11
to lif...@googlegroups.com
Post a snippet of your solution to help others, please.

atta ur rehman

unread,
Aug 9, 2011, 6:40:27 AM8/9/11
to lif...@googlegroups.com
Sure. 

So, the Unicode character for TM is 2122. So, embedding it in the properties file like this works: 

text.left.para2=Product1\u2122 is a simple, affordable cover for...

and in your snippet you simply use S.?("text.left.para2")

On the other hand, I just couldn't make properties like these to work: 

text.left.para2=Product1<sup>TM</sup>is a simple, affordable cover for...

Lift always seems to be escaping any HTML in these strings so that on the page it ends up looking exactly like Product1<sup>TM</sup>is a simple, affordable cover for...

I don't know if there is solution for this problem.

Thanks. 

ATTA


On Mon, Aug 8, 2011 at 4:28 PM, Tyler Weir <tyler...@gmail.com> wrote:
Post a snippet of your solution to help others, please.

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To view this discussion on the web visit https://groups.google.com/d/msg/liftweb/-/u4HN9y5J64YJ.

Todd O'Bryan

unread,
Aug 9, 2011, 7:39:14 AM8/9/11
to lif...@googlegroups.com
By default, Lift escapes all inserted text to avoid nasty exploits.
However, since these are Strings that you've created and can be
confident are safe, you can use
scala.xml.Unparsed(S.?("text.left.para2")) in your snippet. If you
include that in some XML, it outputs the string as is, with no
escaping and no attempt at making sure it's well-formed.

It should go without saying that Unparsed is a major security
vulnerability waiting to happen, so you should only use it if you can
be sure of the string's safety.

Todd

Reply all
Reply to author
Forward
0 new messages