Fix empty domain handling in ResponseCookie
This commit also updates its test to use its intended inputs.
This commit is contained in:
committed by
Rossen Stoyanchev
parent
c24fa22a1b
commit
0f50a9a60a
@@ -248,7 +248,7 @@ public final class ResponseCookie extends HttpCookie {
|
||||
if (lenient && !StringUtils.isEmpty(domain)) {
|
||||
String s = domain.trim();
|
||||
if (s.startsWith("\"") && s.endsWith("\"")) {
|
||||
if (s.substring(1, domain.length() - 1).trim().isEmpty()) {
|
||||
if (s.substring(1, s.length() - 1).trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class ResponseCookieTests {
|
||||
|
||||
Arrays.asList("\"\"", "\t\"\" ", " \" \t \"\t")
|
||||
.forEach(domain -> {
|
||||
ResponseCookie cookie = ResponseCookie.fromClientResponse("id", "1fWa").domain("\"\"").build();
|
||||
ResponseCookie cookie = ResponseCookie.fromClientResponse("id", "1fWa").domain(domain).build();
|
||||
assertThat(cookie.getDomain()).isNull();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user