Issue #4033 - Addressing Lenient URIUtil decode behavior change in test

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2019-08-28 16:32:19 -05:00
parent f47115c585
commit 2fcb311c56
2 changed files with 8 additions and 12 deletions

View File

@ -690,17 +690,12 @@ public class HttpConnectionTest
@Test @Test
public void testBadURIencoding() throws Exception public void testBadURIencoding() throws Exception
{ {
Log.getLogger(HttpParser.class).info("badMessage: bad encoding expected ..."); // The URI is being leniently decoded, leaving the "%x" alone
String response; String response = connector.getResponse("GET /bad/encoding%x HTTP/1.1\r\n" +
"Host: localhost\r\n" +
try (StacklessLogging stackless = new StacklessLogging(HttpParser.class)) "Connection: close\r\n" +
{ "\r\n");
response = connector.getResponse("GET /bad/encoding%1 HTTP/1.1\r\n" + checkContains(response, 0, "HTTP/1.1 200");
"Host: localhost\r\n" +
"Connection: close\r\n" +
"\r\n");
checkContains(response, 0, "HTTP/1.1 400");
}
} }
@Test @Test

View File

@ -1229,11 +1229,12 @@ public class URIUtil
} }
} }
// Don't match on encoded slash
if (ca == '/' && oa != ob) if (ca == '/' && oa != ob)
return false; return false;
if (ca != cb) if (ca != cb)
return URIUtil.decodePath(uriA).equals(URIUtil.decodePath(uriB)); return false;
} }
return a == lenA && b == lenB; return a == lenA && b == lenB;
} }