Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 311972

Summary: HTML editor template doesn't handle "%" signs
Product: [WebTools] Java Server Faces Reporter: Raghunathan Srinivasan <raghunathan.srinivasan>
Component: CoreAssignee: Raghunathan Srinivasan <raghunathan.srinivasan>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: david_williams
Version: 3.2Flags: david_williams: pmc_approved+
raghunathan.srinivasan: pmc_approved? (naci.dai)
raghunathan.srinivasan: pmc_approved? (deboer)
raghunathan.srinivasan: pmc_approved? (neil.hauge)
raghunathan.srinivasan: pmc_approved? (kaloyan)
raghunathan.srinivasan: review+
Target Milestone: 3.2 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard: PMC_approved
Attachments:
Description Flags
Patch to fix Facelet HTML templates none

Description Raghunathan Srinivasan CLA 2010-05-06 16:49:11 EDT
This is a duplicate of bug 242119 :

When I create an HTML editor template extension using the following in the
template.xml text:

&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;&#13;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;&#13;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&#13;
&lt;head&gt;&#13;
&lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"
/&gt;&#13;
&lt;title&gt;Insert title here&lt;/title&gt;&#13;
&lt;/head&gt;&#13;
&lt;body&gt;&#13;
&lt;div
style="background-color:navy;width:100&#37;;color:white"&gt;&lt;/div&gt;&#13;
&lt;/body&gt;&#13;
&lt;/html&gt;

The text "width:100&37;" gets translated when instantiated as "width:100!"
instead of "width:100%" as expected.

Furthermore, in the following template:

&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;&#13;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;&#13;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&#13;
&lt;body&gt;&#13;
&lt;div
style="width:100&#37;;font-size:36px;line-height:48px;background-color:navy;color:white"&gt;My
Facelet Application&lt;/div&gt;&#13;
&lt;/body&gt;&#13;
&lt;/html&gt;

Not only does the width attribute "%" not get correctly translated, but a "!"
is also inserted after the "My" in the "My Facelet Application" text.
Comment 1 Raghunathan Srinivasan CLA 2010-05-06 16:51:56 EDT
Created attachment 167396 [details]
Patch to fix Facelet HTML templates
Comment 2 Raghunathan Srinivasan CLA 2010-05-06 16:56:18 EDT
* Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug"
(requested by an adopter) please document it as such. 
Creating a XHTML page using the header and footer facelet template, the resulting page ignores the '%' character and also inject spurios, '!' character. This is annoying and will affect end-user experience.
* Is there a work-around? If so, why do you believe the work-around is
insufficient? 
Manuall edit the resulting file
* How has the fix been tested? Is there a test case attached to the bugzilla
record? Has a JUnit Test been added? 
Manual testing.
* Give a brief technical overview. Who has reviewed this fix? 
See comment 1
* What is the risk associated with this fix? 
None
Comment 3 David Williams CLA 2010-05-06 22:29:43 EDT
I'm sorry ... its late in the day ... but I don't see what the fix is, here. 

The patch has changes that don't appear to be related to this bug. Fine, looks minor. But worst, I don't see how width:100&37; was changed. Can you spell it out for me? 

Sounds like a good fix for a very important problem, so I'm sure its fine. I'd like to understand the principle that leads to the solution. Is that principle documented? Is there some "best practice" to follow in the future? Or were these some sort of typo.
Comment 4 Raghunathan Srinivasan CLA 2010-05-07 11:58:44 EDT
(In reply to comment #3)
> I'm sorry ... its late in the day ... but I don't see what the fix is, here. 
> 
> The patch has changes that don't appear to be related to this bug. Fine, looks
> minor. But worst, I don't see how width:100&37; was changed. Can you spell it
> out for me? 

The patch moves the HTML text in the template.xml file to a properties file, where width is specified as "width:100%" . When used to create the XHTML file, the '%' is preserved and is not interpreted as a translation string.
> 
> Sounds like a good fix for a very important problem, so I'm sure its fine. I'd
> like to understand the principle that leads to the solution. Is that principle
> documented? Is there some "best practice" to follow in the future? Or were
> these some sort of typo.

From :See https://bugs.eclipse.org/bugs/show_bug.cgi?id=242119#c2 :
Looks to be in Platform code in TemplateReaderWriter. &#37; gets unescaped into
a %, but then the string gets translated starting at that %. Since the string
key is not found in the bundle, you get the !! surrounding the "key" which is
everything up until the newline (where your </div> ends).
Comment 5 David Williams CLA 2010-05-10 14:10:03 EDT
k, thanks for spelling it out for me.
Comment 6 Raghunathan Srinivasan CLA 2010-05-11 00:55:53 EDT
Patch released to RC1