Skip to content

Commit 792b0ca

Browse files
committed
Use equals() instead of matches() to compare URL with view-id. Thanks to mbenson for bringing this up.
1 parent 120906a commit 792b0ca

5 files changed

Lines changed: 87 additions & 1 deletion

File tree

‎CHANGELOG.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Bugfixes:
1111
* Fixed incorrect handling of Spring AOP proxies during bean name lookup - thanks to mbenson for the patch #(119)
1212
* Dynaview: Parameter injection now correctly happens before view determination (#120)
1313
* Fixed decoding of quotation mark character. Thanks to Bruno Aranda for the patch. (#122)
14+
* Use equals() instead of matches() to compare URL with view-id. Thanks to mbenson for bringing this up.
15+
1416

1517
------------------------------------
1618
VERSION 3.3.0

‎core/src/main/java/com/ocpsoft/pretty/PrettyFilter.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void doFilter(final ServletRequest req, final ServletResponse resp, final
101101
query.getParameterMap());
102102

103103
log.trace("Sending mapped request [" + url.toURL() + "] to resource [" + viewId + "]");
104-
if (url.decode().toURL().matches(viewId))
104+
if (url.decode().toURL().equals(viewId))
105105
{
106106
chain.doFilter(wrappedRequest, response);
107107
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.ocpsoft.pretty.faces.test.mapping;
2+
3+
import static org.junit.Assert.assertTrue;
4+
5+
import org.jboss.arquillian.api.Deployment;
6+
import org.jboss.arquillian.junit.Arquillian;
7+
import org.jboss.jsfunit.jsfsession.JSFClientSession;
8+
import org.jboss.jsfunit.jsfsession.JSFSession;
9+
import org.jboss.shrinkwrap.api.spec.WebArchive;
10+
import org.junit.Test;
11+
import org.junit.runner.RunWith;
12+
13+
import com.ocpsoft.pretty.faces.test.PrettyFacesTestBase;
14+
15+
@RunWith(Arquillian.class)
16+
public class SimpleMappingTest extends PrettyFacesTestBase
17+
{
18+
19+
@Deployment
20+
public static WebArchive createDeployment()
21+
{
22+
return PrettyFacesTestBase.createDeployment()
23+
.addResource("mapping/page.xhtml", "page.xhtml")
24+
.addResource("mapping/page.xhtml", "unusual-view-id-(.xhtml")
25+
.addWebResource("mapping/pretty-config.xml", "pretty-config.xml");
26+
}
27+
28+
@Test
29+
public void testSimpleMapping() throws Exception
30+
{
31+
32+
JSFSession jsfSession = new JSFSession("/simple-mapping");
33+
JSFClientSession client = jsfSession.getJSFClientSession();
34+
35+
assertTrue(client.getPageAsText().contains("Mapped view was rendered!"));
36+
37+
}
38+
39+
@Test
40+
public void testUnusualViewId() throws Exception
41+
{
42+
43+
JSFSession jsfSession = new JSFSession("/unusual-view-id");
44+
JSFClientSession client = jsfSession.getJSFClientSession();
45+
46+
assertTrue(client.getPageAsText().contains("Mapped view was rendered!"));
47+
48+
}
49+
50+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3+
<html xmlns="http://www.w3.org/1999/xhtml"
4+
xmlns:f="http://java.sun.com/jsf/core"
5+
xmlns:h="http://java.sun.com/jsf/html"
6+
xmlns:pretty="http://ocpsoft.com/prettyfaces"
7+
xmlns:ui="http://java.sun.com/jsf/facelets">
8+
9+
<head>
10+
<title>Result Page</title>
11+
</head>
12+
13+
<body>
14+
15+
<p>
16+
Mapped view was rendered!
17+
</p>
18+
19+
</body>
20+
21+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2+
3+
<url-mapping id="simple-mapping">
4+
<pattern value="/simple-mapping" />
5+
<view-id value="/page.jsf" />
6+
</url-mapping>
7+
8+
<url-mapping id="unusual-view-id">
9+
<pattern value="/unusual-view-id" />
10+
<view-id value="/unusual-view-id-(.xhtml" />
11+
</url-mapping>
12+
13+
</pretty-config>

0 commit comments

Comments
 (0)