diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/CompressedContentFormat.java b/jetty-http/src/main/java/org/eclipse/jetty/http/CompressedContentFormat.java index 65cdd9b8089..4420e2056e0 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/CompressedContentFormat.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/CompressedContentFormat.java @@ -61,8 +61,8 @@ public class CompressedContentFormat return true; int dashdash = tag.indexOf("--"); - if (dashdash>0) - return etag.regionMatches(0,tag,0,dashdash-2); + if (dashdash>0 && dashdash==etag.length()-1) + return etag.regionMatches(0,tag,0,dashdash); return false; } } diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java index 9aa5bbf123d..65cd960402d 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java @@ -895,6 +895,10 @@ public class DefaultServletTest assertResponseNotContains("Content-Encoding: gzip",response); assertResponseNotContains("ETag: "+etag_gzip,response); assertResponseContains("ETag: ",response); + + String bad_etag_gzip = etag.substring(0,etag.length()-2)+"X--gzip\""; + response = connector.getResponse("GET /context/data0.txt HTTP/1.0\r\nHost:localhost:8080\r\nAccept-Encoding:gzip\r\nIf-None-Match: "+bad_etag_gzip+"\r\n\r\n"); + assertResponseNotContains("304 Not Modified", response); response = connector.getResponse("GET /context/data0.txt HTTP/1.0\r\nHost:localhost:8080\r\nAccept-Encoding:gzip\r\nIf-None-Match: "+etag_gzip+"\r\n\r\n"); assertResponseContains("304 Not Modified", response);