diff --git a/tomcat/src/main/java/org/apache/coyote/http11/common/Cookie.java b/tomcat/src/main/java/org/apache/coyote/http11/common/Cookie.java index b485389a7f..a819a834ef 100644 --- a/tomcat/src/main/java/org/apache/coyote/http11/common/Cookie.java +++ b/tomcat/src/main/java/org/apache/coyote/http11/common/Cookie.java @@ -7,6 +7,9 @@ public class Cookie { private static final String COOKIE_DELIMITER = ";"; + public static final String COOKIE_VALUE_DELIMITER = "="; + public static final int COOKIE_KEY_INDEX = 0; + public static final int COOKIE_VALUE_INDEX = 1; private final Map cookies; @@ -20,8 +23,8 @@ public static Cookie from(String cookieValue) { } Map cookies = Arrays.stream(cookieValue.split(COOKIE_DELIMITER)) - .map(cookieElement -> cookieElement.trim().split("=")) - .collect(Collectors.toMap(cookie -> cookie[0], cookie -> cookie[1])); + .map(cookieElement -> cookieElement.trim().split(COOKIE_VALUE_DELIMITER)) + .collect(Collectors.toMap(cookie -> cookie[COOKIE_KEY_INDEX], cookie -> cookie[COOKIE_VALUE_INDEX])); return new Cookie(cookies); }