Issue Details (XML | Word | Printable)

Key: JAVASERVERFACES_SPEC_PUBLIC-1019
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Ed Burns
Reporter: ejp
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
javaserverfaces-spec-public

h:outputLink etc strange URL encoding

Created: 16/Jun/11 05:53 PM   Updated: 03/Dec/12 07:10 AM   Resolved: 17/Jun/11 06:06 PM
Component/s: Components/Renderers
Affects Version/s: 2.1
Fix Version/s: 2.2

Time Tracking:
Original Estimate: Not Specified
Remaining Estimate: 0 minutes
Remaining Estimate - 0 minutes
Time Spent: 1 hour, 13 minutes
Time Spent - 1 hour, 13 minutes

File Attachments: 1. Text File 20110617_i_spec_1019.patch (13 kB) 17/Jun/11 02:47 PM - Ed Burns

Environment:

All

Issue Links:
Dependency
 

Tags:
Participants: Ed Burns and ejp


 Description  « Hide

If I have an h:outputLink with a value containing spaces, it is rendered with the spaces converted to +.

It seems to me that if it is going to convert this at all, it should do so correctly, i.e. to %20. Alternatively it should leave it alone and let it fail as originally supplied.

Am I missing something here?

I have a legacy content database where the document index provides URLs contain spaces. I can change that, and probably will, but maybe this is a bug and will get fixed the way I would like?

Discussion <a href="http://forums.oracle.com/forums/thread.jspa?messageID=9639501&#9639501">here</a>. Appears to involve use of URLEncoder for the one thing it cannot do, which is encode a URL. Should be using URI.toASCIIString().



Ed Burns made changes - 17/Jun/11 11:42 AM
Field Original Value New Value
Status Open [ 1 ] In Progress [ 3 ]
Ed Burns added a comment - 17/Jun/11 12:52 PM

You are correct in filing this as a spec issue, because the problem stems from the specification for the renderer for javax.faces.Output javax.faces.Link.

http://javaserverfaces.java.net/nonav/docs/2.1/renderkitdocs/index.html

The entire "href" string must be passed through a call to the encodeResourceURL() method of the ExternalContext.

Which ends up calling: javax.servlet.http.HttpServletResponse method encodeURL(url).


Ed Burns logged work - 17/Jun/11 01:54 PM
Time Worked: 20 minutes
<No comment>
Ed Burns made changes - 17/Jun/11 01:54 PM
Remaining Estimate 0 minutes [ 0 ]
Time Spent 20 minutes [ 1200 ]
Ed Burns made changes - 17/Jun/11 02:29 PM
Ed Burns added a comment - 17/Jun/11 02:47 PM

checkpoint


Ed Burns made changes - 17/Jun/11 02:47 PM
Attachment 20110617_i_spec_1019.patch [ 46364 ]
Ed Burns logged work - 17/Jun/11 02:48 PM
Time Worked: 53 minutes
<No comment>
Ed Burns made changes - 17/Jun/11 02:48 PM
Time Spent 20 minutes [ 1200 ] 1 hour, 13 minutes [ 4380 ]
Ed Burns added a comment - 17/Jun/11 06:06 PM

Sending jsf-api/doc/standard-html-renderkit-base.xml
Sending jsf-api/doc/standard-html-renderkit.xml
Sending jsf-api/src/main/java/javax/faces/context/ResponseWriter.java
Sending jsf-ri/src/main/java/com/sun/faces/util/HtmlUtils.java
Sending jsf-ri/systest/build-tests.xml
Adding jsf-ri/systest/web/render/outputLinkSpaces.jsp
Sending jsf-tools/src/main/resources/com/sun/faces/generate/facesdoc/stylesheet.css
Transmitting file data .......
Committed revision 9175.


Ed Burns made changes - 17/Jun/11 06:06 PM
Status In Progress [ 3 ] Resolved [ 5 ]
Fix Version/s 2.2 [ 10403 ]
Resolution Fixed [ 1 ]
ejp added a comment - 17/Jun/11 09:23 PM

As a workaround until this fix is released, you can add the following converter to the h:outputLink element:

public class URLConverter implements Converter
{
@Override
public Object getAsObject(FacesContext fc, UIComponent uic, String string)

{ return string; }

@Override
public String getAsString(FacesContext fc, UIComponent uic, Object object)
{
String path = object.toString();
try

{ if (path.indexOf(' ') >= 0) path = new URI(null, path, null).toASCIIString(); }

catch (URISyntaxException exc)

{ // logger.log(Level.SEVERE, "uri="+path, exc); }

return path;
}
}


Ed Burns made changes - 19/Nov/12 11:21 PM
Component/s Components/Renderers [ 10216 ]
ejp added a comment - 03/Dec/12 07:09 AM - edited

The same problem also turns up in h:graphicImage. For example:

h:graphicImage value="{{lab.path}}VisualObjective.jpg" where lab.path evaluates to /cLabsTest/EDSILabs/vLearning/Cisco Courses/Enterprise (Routers & Switches)/Interconnecting Cisco Network Devices 1/ICND1 Lab 2-2 Performing Switch Startup and Initial Configuration/VisualObjective.jpg

becomes

img src="/cLabsTest/EDSILabs/vLearning/Cisco+Courses/Enterprise+(Routers+&+Switches)/Interconnecting+Cisco+Network+Devices+1/ICND1+Lab+2-2+Performing+Switch+Startup+and+Initial+Configuration/VisualObjective.jpg"

Should I report this as a new bug?