Author: markt
Date: Mon Sep 9 20:10:48 2013
New Revision: 1521273
URL: http://svn.apache.org/r1521273
Log:
UriTemplate should not trigger failures for '/' for for instances used for
matching that end in '/'
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/UriTemplate.java
tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/server/TestUriTemplate.java
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1521271
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/UriTemplate.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/UriTemplate.java?rev=1521273&r1=1521272&r2=1521273&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/UriTemplate.java
(original)
+++
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/server/UriTemplate.java
Mon Sep 9 20:10:48 2013
@@ -60,9 +60,11 @@ public class UriTemplate {
for (int i = 0; i < segments.length; i++) {
String segment = segments[i];
if (segment.length() == 0) {
- if (i == 0) {
+ if (i == 0 || (i == segments.length - 1 && paramCount == 0)) {
// Ignore the first empty segment as the path must always
// start with '/'
+ // Ending with a '/' is also OK for instances used for
+ // matches but not for parameterised templates.
continue;
} else {
// As per EG discussion, all other empty segments are
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/server/TestUriTemplate.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/server/TestUriTemplate.java?rev=1521273&r1=1521272&r2=1521273&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/server/TestUriTemplate.java
(original)
+++
tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/server/TestUriTemplate.java
Mon Sep 9 20:10:48 2013
@@ -171,19 +171,19 @@ public class TestUriTemplate {
}
- @Test(expected=java.lang.IllegalArgumentException.class)
public void testEgMailingList01() throws Exception {
UriTemplate t = new UriTemplate("/a/{var}");
- @SuppressWarnings("unused")
Map<String,String> result = t.match(new UriTemplate("/a/b/"));
+
+ Assert.assertNull(result);
}
- @Test(expected=java.lang.IllegalArgumentException.class)
public void testEgMailingList02() throws Exception {
UriTemplate t = new UriTemplate("/a/{var}");
- @SuppressWarnings("unused")
Map<String,String> result = t.match(new UriTemplate("/a/"));
+
+ Assert.assertNull(result);
}
@@ -202,4 +202,12 @@ public class TestUriTemplate {
@SuppressWarnings("unused")
Map<String,String> result = t.match(new UriTemplate("/a//c"));
}
+
+
+ @Test(expected=java.lang.IllegalArgumentException.class)
+ public void testEgMailingList05() throws Exception {
+ UriTemplate t = new UriTemplate("/a/{var}/");
+ @SuppressWarnings("unused")
+ Map<String,String> result = t.match(new UriTemplate("/a/b/"));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]