Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h:outputLink etc strange URL encoding #1019

Closed
eclipse-faces-bot opened this issue Jun 16, 2011 · 12 comments
Closed

h:outputLink etc strange URL encoding #1019

eclipse-faces-bot opened this issue Jun 16, 2011 · 12 comments

Comments

@eclipse-faces-bot
Copy link

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 here. Appears to involve use of URLEncoder for the one thing it cannot do, which is encode a URL. Should be using URI.toASCIIString().

Environment

All

Affected Versions

[2.1]

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Reported by ejp

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Issue-Links:
depends on
JAVASERVERFACES_SPEC_PUBLIC-479

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
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).

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
checkpoint

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
File: 20110617_i_spec_1019.patch
Attached By: @edburns

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
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.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Marked as fixed on Friday, June 17th 2011, 11:06:42 am

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
ejp said:
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;
}
}

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
ejp said:
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?

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@manfredriem said:
Closing resolved issue out

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
This issue was imported from java.net JIRA JAVASERVERFACES_SPEC_PUBLIC-1019

@eclipse-faces-bot
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant