neharob / prettyfaces

Automatically exported from code.google.com/p/prettyfaces
0 stars 0 forks source link

URL mapping with regexp pattern using OR causes StringIndexOutOfBoundsException #63

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Mapping defined via regexp pattern using |. See attached snippet
2. Uri matching the snippet entered, eg: index.jsf
3. java.lang.StringIndexOutOfBoundsException: String index out of range: -109
    java.lang.String.substring(String.java:1937)
    java.lang.String.substring(String.java:1904)
    com.ocpsoft.pretty.faces.url.URLPatternParser.parse(URLPatternParser.java:168)
    com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:91)

See attached debug from NetBeans with variable tracking in attached jpg.

This issue appears after migrating from ocpsoft-pretty-faces-2.0.4.jar to 
prettyfaces-jsf2-3.1.0.jar.
The previous version ocpsoft-pretty-faces-2.0.4.jarperformed the mapping 
without error. 

Original issue reported on code.google.com by jamaja...@gmail.com on 1 Oct 2010 at 4:33

Attachments:

GoogleCodeExporter commented 9 years ago
This does seem to be a bug, but in the mean time could you try a mapping like 
this? It should work:

<url-mapping id="langforward_index">
   <pattern value="/#{/(index|insert_trip|login|register|virtualniprohlidky_360panorama|investors|links|detail|about_us|kapitanske_zkousky)/ page}.jsf"></pattern>
   <view-id>/lang_switch.jsp</view-id>               
</url-mapping>

Original comment by lincolnb...@gmail.com on 1 Oct 2010 at 5:50

GoogleCodeExporter commented 9 years ago
Or like this:

<url-mapping id="langforward_index">
   <pattern value="/#{/(index|insert_trip|login|register|virtualniprohlidky_360panorama|investors|links|detail|about_us|kapitanske_zkousky).jsf/ page}"></pattern>
   <view-id>/lang_switch.jsp</view-id>               
</url-mapping>

Original comment by lincolnb...@gmail.com on 1 Oct 2010 at 5:51

GoogleCodeExporter commented 9 years ago
Just committed the fix + tests for this. Try version 3.1.1-SNAPSHOT when it is 
built by CI and deployed to the maven repository in about 15-20 minutes.

Thanks very much for pointing this out.

--Lincoln

Original comment by lincolnb...@gmail.com on 1 Oct 2010 at 6:17

GoogleCodeExporter commented 9 years ago
Oh, and please let me know if that works for you :) Thanks.

Original comment by lincolnb...@gmail.com on 1 Oct 2010 at 6:18

GoogleCodeExporter commented 9 years ago
For now I can confirm that both workaround mapping helped me. Later on I'll 
test the snapshot. Thanks for quick response.

Original comment by jamaja...@gmail.com on 1 Oct 2010 at 6:24

GoogleCodeExporter commented 9 years ago

Original comment by lincolnb...@gmail.com on 1 Oct 2010 at 6:24