Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2015-06-19 02:48:53 -0400
committerGreg Wilkins2015-06-19 02:48:53 -0400
commit3e401a62e9e60accfa8550d7c45e0b659ff6ff88 (patch)
tree8ced9a866a0f07f6e60a63c77930bf009da20e2d /jetty-servlets
parent9d8d56b401c3fdc20b8aa8b5bffacb5db2b3728a (diff)
downloadorg.eclipse.jetty.project-3e401a62e9e60accfa8550d7c45e0b659ff6ff88.tar.gz
org.eclipse.jetty.project-3e401a62e9e60accfa8550d7c45e0b659ff6ff88.tar.xz
org.eclipse.jetty.project-3e401a62e9e60accfa8550d7c45e0b659ff6ff88.zip
StringUtil.csvSplit(String)
Diffstat (limited to 'jetty-servlets')
-rw-r--r--jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CrossOriginFilter.java11
-rw-r--r--jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java3
-rw-r--r--jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java5
-rw-r--r--jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PutFilter.java3
-rw-r--r--jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PutFilterTest.java5
5 files changed, 16 insertions, 11 deletions
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CrossOriginFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CrossOriginFilter.java
index f5cf2b0d97..1ff6333128 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CrossOriginFilter.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CrossOriginFilter.java
@@ -36,6 +36,7 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@@ -155,7 +156,7 @@ public class CrossOriginFilter implements Filter
String allowedOriginsConfig = config.getInitParameter(ALLOWED_ORIGINS_PARAM);
if (allowedOriginsConfig == null)
allowedOriginsConfig = "*";
- String[] allowedOrigins = allowedOriginsConfig.split(",");
+ String[] allowedOrigins = StringUtil.csvSplit(allowedOriginsConfig);
for (String allowedOrigin : allowedOrigins)
{
allowedOrigin = allowedOrigin.trim();
@@ -178,7 +179,7 @@ public class CrossOriginFilter implements Filter
if (allowedMethodsConfig == null)
allowedMethods.addAll(DEFAULT_ALLOWED_METHODS);
else
- allowedMethods.addAll(Arrays.asList(allowedMethodsConfig.split(",")));
+ allowedMethods.addAll(Arrays.asList(StringUtil.csvSplit(allowedMethodsConfig)));
String allowedHeadersConfig = config.getInitParameter(ALLOWED_HEADERS_PARAM);
if (allowedHeadersConfig == null)
@@ -186,7 +187,7 @@ public class CrossOriginFilter implements Filter
else if ("*".equals(allowedHeadersConfig))
anyHeadersAllowed = true;
else
- allowedHeaders.addAll(Arrays.asList(allowedHeadersConfig.split(",")));
+ allowedHeaders.addAll(Arrays.asList(StringUtil.csvSplit(allowedHeadersConfig)));
String preflightMaxAgeConfig = config.getInitParameter(PREFLIGHT_MAX_AGE_PARAM);
if (preflightMaxAgeConfig == null)
@@ -208,7 +209,7 @@ public class CrossOriginFilter implements Filter
String exposedHeadersConfig = config.getInitParameter(EXPOSED_HEADERS_PARAM);
if (exposedHeadersConfig == null)
exposedHeadersConfig = "";
- exposedHeaders.addAll(Arrays.asList(exposedHeadersConfig.split(",")));
+ exposedHeaders.addAll(Arrays.asList(StringUtil.csvSplit(exposedHeadersConfig)));
String chainPreflightConfig = config.getInitParameter(OLD_CHAIN_PREFLIGHT_PARAM);
if (chainPreflightConfig != null)
@@ -419,7 +420,7 @@ public class CrossOriginFilter implements Filter
return Collections.emptyList();
List<String> requestedHeaders = new ArrayList<String>();
- String[] headers = accessControlRequestHeaders.split(",");
+ String[] headers = StringUtil.csvSplit(accessControlRequestHeaders);
for (String header : headers)
{
String h = header.trim();
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java
index a1ded0b394..fad67d2721 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java
@@ -52,6 +52,7 @@ import javax.servlet.http.HttpSessionBindingListener;
import javax.servlet.http.HttpSessionEvent;
import org.eclipse.jetty.server.handler.ContextHandler;
+import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.annotation.ManagedOperation;
@@ -1043,7 +1044,7 @@ public class DoSFilter implements Filter
public void setWhitelist(String commaSeparatedList)
{
List<String> result = new ArrayList<>();
- for (String address : commaSeparatedList.split(","))
+ for (String address : StringUtil.csvSplit(commaSeparatedList))
addWhitelistAddress(result, address);
clearWhitelist();
_whitelist.addAll(result);
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java
index 2565a0276e..038865dfa3 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java
@@ -46,6 +46,7 @@ import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.server.Dispatcher;
import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
@@ -95,11 +96,11 @@ public class PushCacheFilter implements Filter
String hosts = config.getInitParameter("hosts");
if (hosts != null)
- Collections.addAll(_hosts, hosts.split(","));
+ Collections.addAll(_hosts, StringUtil.csvSplit(hosts));
String ports = config.getInitParameter("ports");
if (ports != null)
- for (String p : ports.split(","))
+ for (String p : StringUtil.csvSplit(ports))
_ports.add(Integer.parseInt(p));
// Expose for JMX.
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PutFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PutFilter.java
index b31ab31840..24a1b75ede 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PutFilter.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PutFilter.java
@@ -44,6 +44,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import org.eclipse.jetty.util.IO;
+import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.URIUtil;
/**
@@ -331,7 +332,7 @@ public class PutFilter implements Filter
if ("Allow".equalsIgnoreCase(name))
{
Set<String> options = new HashSet<String>();
- options.addAll(Arrays.asList(value.split(" *, *")));
+ options.addAll(Arrays.asList(StringUtil.csvSplit(value)));
options.addAll(_operations);
value=null;
for (String o : options)
diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PutFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PutFilterTest.java
index dbce361080..d656eaf3bb 100644
--- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PutFilterTest.java
+++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/PutFilterTest.java
@@ -41,6 +41,7 @@ import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.ServletTester;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.IO;
+import org.eclipse.jetty.util.StringUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -266,8 +267,8 @@ public class PutFilterTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
Set<String> options = new HashSet<String>();
- options.addAll(Arrays.asList(response.get("Allow").split(" *, *")));
-
+ String allow=response.get("Allow");
+ options.addAll(StringUtil.csvSplit(null,allow,0,allow.length()));
assertTrue(options.contains("GET"));
assertTrue(options.contains("POST"));
assertTrue(options.contains("PUT"));

Back to the top