Issue Details (XML | Word | Printable)

Key: MYFACES-1841
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Leonardo Uribe
Reporter: Lorenzo Cerulli
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
MyFaces Core

HtmlResponseWriterImpl.writeURIAttribute does not perform proper URLs encoding ( ex: & should be encoded in &amp)

Created: 23/Mar/08 08:07 PM   Updated: 01/Jun/09 11:26 PM
Return to search
Component/s: General, Portlet_Support
Affects Version/s: 1.1.4, 1.1.5, 1.2.0
Fix Version/s: 1.1.7, 1.2.7

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works MYFACES-1841-1.patch 2009-05-26 04:22 AM Leonardo Uribe 22 kB
Environment: Windows xp sp2->Jboss portal 2.4.2->tomcat 5.5 ->JSF portlet
Issue Links:
Reference
 

Resolution Date: 28/May/09 02:36 AM


 Description  « Hide
HtmlFormRenderer is the class in charge of rendering the UIForm component and all the required attibutes.
This class is in charge of rendering for example the Form component tinto <form id="foo" name="bar" action=/HelloWorldJSFPortletWindow?action=1&org.apache.myfaces.portlet.MyFacesGenericPortlet.VIEW_ID=%2FWEB-INF%2Fjsp%2Findex. .....> </form>

During the rendering process the form renderer uses HtmlResponseWriterImpl.writeURIAttribute to write the "action" attribute of the form component.

Generally speaking the action attribute should be acquired using "context.getApplication().getViewHandler().getActionURL(context, viewid))" and the result MUST be encoded using "context.getExternalContext().encodeActionURL" before passing the url to the "HtmlResponseWriterImpl.writeURIAttribute(URL);" This way the URL will be well formed and will be correctly encoded in the action attribute.

Even if the HtmlFormRendererBase for example correctly implements this process the resulting URL is encoded in the action attribute without correctly transforming "&" in "&amp".

At this point we can argue that this bug could be generated by two different sources:

1. Not correct URL encding perfomed by javax.faces.context.FacesContext during context.getExternalContext().encodeActionURL[this is non related to myfaces and probably depend on the PortletResponse object implemented by the container JBOSS portal in this case]
2. Nor correct URI encoding within HtmlResponseWriterImpl.writeURIAttribute(URL) [related to myfaces]

Analyzing the source code of the latter i noticed that writeURIAttribute(URL) internally calls the HTMLEncoder.encode method to perform string encoding if the URI starts with the "javascript" prefix otherwise does not perform any kind of encoding.
Probably this is a bug bacause an enforcment of URI encoding rules should be provided in any case;







 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #779411 Thu May 28 02:36:00 UTC 2009 lu4242 MYFACES-1841 HtmlResponseWriterImpl.writeURIAttribute does not perform proper URLs encoding ( ex: & should be encoded in &amp)
Files Changed
MODIFY /myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java
MODIFY /myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java

Repository Revision Date User Message
ASF #779412 Thu May 28 02:36:25 UTC 2009 lu4242 MYFACES-1841 HtmlResponseWriterImpl.writeURIAttribute does not perform proper URLs encoding ( ex: & should be encoded in &amp)
Files Changed
MODIFY /myfaces/shared/trunk_3.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java
MODIFY /myfaces/shared/trunk_3.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java
MODIFY /myfaces/shared/trunk_3.0.x/core/src/test/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoderTest.java