You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/06/25 12:08:11 UTC
svn commit: r1496398 - in
/tomcat/trunk/java/org/apache/tomcat/websocket/server:
LocalStrings.properties UriTemplate.java WsServerContainer.java
Author: markt
Date: Tue Jun 25 10:08:11 2013
New Revision: 1496398
URL: http://svn.apache.org/r1496398
Log:
WebSocket 1.0. Section 4.1.1
Improve path validation
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties
tomcat/trunk/java/org/apache/tomcat/websocket/server/UriTemplate.java
tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties?rev=1496398&r1=1496397&r2=1496398&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/server/LocalStrings.properties Tue Jun 25 10:08:11 2013
@@ -22,6 +22,7 @@ serverContainer.pojoDeploy=POJO class [{
serverContainer.servletContextMismatch=Attempted to register a POJO annotated for WebSocket at path [{0}] in the ServletContext with context path [{1}] when the WebSocket ServerContainer is allocated to the ServletContext with context path [{2}]
serverContainer.servletContextMissing=No ServletContext was specified
+uriTemplate.invalidPath=The path [{0}] is not valid.
uriTemplate.invalidSegment=The segment [{0}] is not valid in the provided path [{1}]
wsHttpUpgradeHandler.destroyFailed=Failed to close WebConnection while destroying the WebSocket HttpUpgradeHandler
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/server/UriTemplate.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/UriTemplate.java?rev=1496398&r1=1496397&r2=1496398&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/server/UriTemplate.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/server/UriTemplate.java Tue Jun 25 10:08:11 2013
@@ -22,6 +22,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import javax.websocket.DeploymentException;
+
import org.apache.tomcat.util.res.StringManager;
/**
@@ -38,7 +40,13 @@ public class UriTemplate {
private final boolean hasParameters;
- public UriTemplate(String path) {
+ public UriTemplate(String path) throws DeploymentException {
+
+ if (path == null || path.length() ==0 || !path.startsWith("/")) {
+ throw new DeploymentException(
+ sm.getString("uriTemplate.invalidPath", path));
+ }
+
StringBuilder normalized = new StringBuilder(path.length());
String[] segments = path.split("/");
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java?rev=1496398&r1=1496397&r2=1496398&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java Tue Jun 25 10:08:11 2013
@@ -190,7 +190,7 @@ public class WsServerContainer extends W
try {
configurator = annotation.configurator().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
- throw new IllegalStateException(sm.getString(
+ throw new DeploymentException(sm.getString(
"serverContainer.configuratorFail",
annotation.configurator().getName(),
pojo.getClass().getName()), e);
@@ -232,7 +232,13 @@ public class WsServerContainer extends W
}
// No exact match. Need to look for template matches.
- UriTemplate pathUriTemplate = new UriTemplate(path);
+ UriTemplate pathUriTemplate = null;
+ try {
+ pathUriTemplate = new UriTemplate(path);
+ } catch (DeploymentException e) {
+ // Path is not valid so can't be matched to a WebSocketEndpoint
+ return null;
+ }
// Number of segments has to match
Integer key = Integer.valueOf(pathUriTemplate.getSegmentCount());
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org