Fixes #1592 bad compressed etag comparison

This commit is contained in:
Greg Wilkins 2017-06-06 10:06:48 +02:00 committed by Joakim Erdfelt
parent 88617b9233
commit 58a4d9e115
2 changed files with 6 additions and 2 deletions

View File

@ -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;
}
}

View File

@ -896,6 +896,10 @@ public class DefaultServletTest
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);
assertResponseContains("ETag: "+etag_gzip,response);