You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org> on 2015/09/12 01:05:46 UTC

[jira] [Commented] (MYFACES-4009) outputLink URL encoding

    [ https://issues.apache.org/jira/browse/MYFACES-4009?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14741688#comment-14741688 ] 

Leonardo Uribe commented on MYFACES-4009:
-----------------------------------------

I tried some examples with Mojarra 2.2.12 and it renders the same as MyFaces, but I notice that in this case:

<h:outputLink value="box1.xhtml?id=some value">

the space is percent encoded (space replaced by %20). 

But the query params coming from f:param for h:link, h:outputLink and h:commandLink are encoded using java.net.URLEncoder.encode(...). 

In JSF 2.2 spec renderkit doc for component-family: javax.faces.OutcomeTarget renderer-type: javax.faces.Button there is a section titled:

"Algorithm to obtain the url to which the user-agent should issue a GET request when clicked"

It says this:

"... The entire target URL string must be processed by a call to the encodeResourceURL() method of the ExternalContext. The name of the UIParameter goes on the left hand side, and the value of the UIParameter on the right hand side. The name and the value must be URLEncoded. Each UIParameter instance is separeted by an ampersand, as dictated in the URL spec.  ..."

In this case we have a situation where the same string is encoded multiple times:

- Call to URLEncoder.encode(...) for each parameter provided by f:param tag
- In ResponseWriter.writeURIAttribute(...)

ExternalContext.encodeResourceURL() internally calls httpServletResponse.encodeURL(...), but this is not used to do the url encoding (it is called later on the same algorithm, so that part is fine).

This issue needs to be discussed at spec level. I'll create an issue for this one.



> outputLink URL encoding 
> ------------------------
>
>                 Key: MYFACES-4009
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4009
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.2.8
>            Reporter: Bill Lucy
>            Priority: Minor
>         Attachments: myfaces-4009.patch
>
>
> We have an interesting behaviour when rendering h:outputLink with nested f:param elements: in the param data, the output href string has spaces encoded with a "+" rather than the expected "%20".  For example:
> <h:outputLink value="login.xhtml"><h:outputText value="Login page" /><f:param name="username" value="This is a test" /></h:outputLink>
> creates the following:
> <a href="login.xhtml?username=This+is+a+test">Login page</a>
> This already seems to have been discussed in https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1019
> I'll attach a patch which resolves this - if it is in fact an issue.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)