From 17d281fa7c1965687c9d1a0af6dfbbaae1ce3f22 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Mon, 25 Nov 2013 10:24:17 +1100 Subject: [PATCH] 422386 Comma-separated s not trimmed in GzipFilter --- .../java/org/eclipse/jetty/servlets/GzipFilter.java | 12 ++++++------ .../jetty/servlets/GzipFilterDefaultTest.java | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java index 6e15fa1728c..6f6da630074 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java @@ -218,14 +218,14 @@ public class GzipFilter extends UserAgentFilter { StringTokenizer tok = new StringTokenizer(tmp,",",false); while (tok.hasMoreTokens()) - _mimeTypes.add(tok.nextToken()); + _mimeTypes.add(tok.nextToken().trim()); } } else { StringTokenizer tok = new StringTokenizer(tmp,",",false); while (tok.hasMoreTokens()) - _mimeTypes.add(tok.nextToken()); + _mimeTypes.add(tok.nextToken().trim()); } tmp=filterConfig.getInitParameter("excludedAgents"); if (tmp!=null) @@ -233,7 +233,7 @@ public class GzipFilter extends UserAgentFilter _excludedAgents=new HashSet(); StringTokenizer tok = new StringTokenizer(tmp,",",false); while (tok.hasMoreTokens()) - _excludedAgents.add(tok.nextToken()); + _excludedAgents.add(tok.nextToken().trim()); } tmp=filterConfig.getInitParameter("excludeAgentPatterns"); @@ -242,7 +242,7 @@ public class GzipFilter extends UserAgentFilter _excludedAgentPatterns=new HashSet(); StringTokenizer tok = new StringTokenizer(tmp,",",false); while (tok.hasMoreTokens()) - _excludedAgentPatterns.add(Pattern.compile(tok.nextToken())); + _excludedAgentPatterns.add(Pattern.compile(tok.nextToken().trim())); } tmp=filterConfig.getInitParameter("excludePaths"); @@ -251,7 +251,7 @@ public class GzipFilter extends UserAgentFilter _excludedPaths=new HashSet(); StringTokenizer tok = new StringTokenizer(tmp,",",false); while (tok.hasMoreTokens()) - _excludedPaths.add(tok.nextToken()); + _excludedPaths.add(tok.nextToken().trim()); } tmp=filterConfig.getInitParameter("excludePathPatterns"); @@ -260,7 +260,7 @@ public class GzipFilter extends UserAgentFilter _excludedPathPatterns=new HashSet(); StringTokenizer tok = new StringTokenizer(tmp,",",false); while (tok.hasMoreTokens()) - _excludedPathPatterns.add(Pattern.compile(tok.nextToken())); + _excludedPathPatterns.add(Pattern.compile(tok.nextToken().trim())); } tmp=filterConfig.getInitParameter("vary"); diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java index 1aaa3010977..21f10d41185 100644 --- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java +++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipFilterDefaultTest.java @@ -117,7 +117,7 @@ public class GzipFilterDefaultTest FilterHolder holder = tester.setContentServlet(GetServlet.class); holder.setInitParameter("mimeTypes","text/plain"); - holder.setInitParameter("methods","POST,WIBBLE"); + holder.setInitParameter("methods","POST, WIBBLE"); try { @@ -441,7 +441,7 @@ public class GzipFilterDefaultTest GzipTester tester = new GzipTester(testingdir,compressionType); FilterHolder holder = tester.setContentServlet(DefaultServlet.class); - holder.setInitParameter("excludedAgents","foo"); + holder.setInitParameter("excludedAgents","bar, foo"); tester.setUserAgent("foo"); int filesize = CompressedResponseWrapper.DEFAULT_BUFFER_SIZE * 4; @@ -488,7 +488,7 @@ public class GzipFilterDefaultTest GzipTester tester = new GzipTester(testingdir,compressionType); FilterHolder holder = tester.setContentServlet(DefaultServlet.class); - holder.setInitParameter("excludePaths","/context/"); + holder.setInitParameter("excludePaths","/bar/, /context/"); int filesize = CompressedResponseWrapper.DEFAULT_BUFFER_SIZE * 4; tester.prepareServerFile("file.txt",filesize);