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

Problem with # character in request parameters #224

Closed
jllado opened this issue Mar 2, 2016 · 5 comments
Closed

Problem with # character in request parameters #224

jllado opened this issue Mar 2, 2016 · 5 comments

Comments

@jllado
Copy link

jllado commented Mar 2, 2016

When I activate prettyfaces then I have the following error when trying to pass a request parameter with # character:

java.lang.IllegalArgumentException: [/home.xhtml?agency=agt##2206] is not a valid URL fragment. Consider encoding relevant portions of the URL with [class org.ocpsoft.urlbuilder.util.Encoder]
at org.ocpsoft.urlbuilder.AddressBuilder.create(AddressBuilder.java:89) ~[rewrite-addressbuilder-2.0.12.Final.jar:2.0.12.Final]
at org.ocpsoft.rewrite.servlet.impl.HttpRewriteWrappedResponse.encodeRedirectURL(HttpRewriteWrappedResponse.java:377) ~[rewrite-servlet-2.0.12.Final.jar:2.0.12.Final]
at org.apache.myfaces.context.servlet.ServletExternalContextImpl.encodeRedirectURL(ServletExternalContextImpl.java:385) ~[myfaces-impl-2.2.9.jar:2.2.9]
at javax.faces.context.ExternalContextWrapper.encodeRedirectURL(ExternalContextWrapper.java:96) ~[myfaces-api-2.2.9.jar:2.2.9]
at org.apache.myfaces.application.ViewHandlerImpl.getRedirectURL(ViewHandlerImpl.java:174) ~[myfaces-impl-2.2.9.jar:2.2.9]
at org.apache.webbeans.jsf.ConversationAwareViewHandler.getRedirectURL(ConversationAwareViewHandler.java:89) ~[openwebbeans-jsf-1.6.2.jar:1.6.2]
at org.ocpsoft.rewrite.faces.RewriteViewHandler.getRedirectURL(RewriteViewHandler.java:173) ~[rewrite-integration-faces-2.0.12.Final.jar:2.0.12.Final]
at javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:126) ~[myfaces-api-2.2.9.jar:2.2.9]
at javax.faces.application.ViewHandlerWrapper.getRedirectURL(ViewHandlerWrapper.java:126) ~[myfaces-api-2.2.9.jar:2.2.9]
at org.apache.myfaces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:185) ~[myfaces-impl-2.2.9.jar:2.2.9]
at org.apache.myfaces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:122) ~[myfaces-impl-2.2.9.jar:2.2.9]
at com.ocpsoft.pretty.faces2.application.PrettyNavigationHandler.handleNavigation(PrettyNavigationHandler.java:65) ~[rewrite-config-prettyfaces-2.0.12.Final.jar:2.0.12.Final]
at org.ocpsoft.rewrite.faces.RewriteNavigationHandler.handleNavigation(RewriteNavigationHandler.java:64) ~[rewrite-integration-faces-2.0.12.Final.jar:2.0.12.Final]
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:140) ~[myfaces-impl-2.2.9.jar:2.2.9]
at javax.faces.component.UICommand.broadcast(UICommand.java:120) ~[myfaces-api-2.2.9.jar:2.2.9]

Any idea?

I’m using latest version of prettyfaces:

<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-servlet</artifactId>
<version>2.0.12.Final</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-config-prettyfaces</artifactId>
<version>2.0.12.Final</version>
</dependency>

I also tried with last snapshot but I got the same error :S.

<dependency>
  <groupId>org.ocpsoft.rewrite</groupId>
  <artifactId>rewrite-servlet</artifactId>
  <version>3.0.0-SNAPSHOT</version>
</dependency>

Thanks!

@chkal
Copy link
Member

chkal commented Mar 2, 2016

One problem I see is that the URL doesn't look valid:

/home.xhtml?agency=agt##2206

Are you trying to set the value of the param agency to agt##2206? In this case you have to escape the # characters as they are using to separate the fragment from the rest of the URI.

If you are trying to define a fragment named #2206, the URI is also illegal. Fragment identifiers must not contains # characters.

@jllado
Copy link
Author

jllado commented Mar 2, 2016

Mmmm, it's true. I've checked that the AddressBuilder is using the java.net.URI class. So when new URI(...) is called, then the parse method throws a URISyntaxException... :_(

But for us it's an unexpected behaviour because it works without prettyfaces :S

@chkal
Copy link
Member

chkal commented Mar 3, 2016

I see that this is unexpected for you as it worked fine before. But PrettyFaces has to parse URLs for being able to modify them. And invalid URLs are a really problem in this case. We are using java.net.URI because it implements the URI RFC correctly and can be considered to do its job. Of cause it would be possible to create a custom parser, which is more fault tolerant, but I guess that's a lot of work. :(

@lincolnthree
Copy link
Member

This may be solved by the recent fix for #195 - I just added some tests to verify. Looking good so far.

chkal added a commit that referenced this issue Jul 19, 2016
Encoding fixes and fixes for #195 and #224
@lincolnthree
Copy link
Member

Should be resolved in Rewrite 3.4.1.Final

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

No branches or pull requests

3 participants