diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/CookieCutter.java b/jetty-server/src/main/java/org/eclipse/jetty/server/CookieCutter.java index 65c93517404..a154bb72085 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/CookieCutter.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/CookieCutter.java @@ -281,8 +281,8 @@ public class CookieCutter if (value!=null && name!=null) { // TODO handle unquoting during parsing! But quoting is uncommon - name=QuotedStringTokenizer.unquote(name); - value=QuotedStringTokenizer.unquote(value); + name=QuotedStringTokenizer.unquoteOnly(name); + value=QuotedStringTokenizer.unquoteOnly(value); try { diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java b/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java index b2ce0fa1a69..8dc0a816f8f 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/QuotedStringTokenizer.java @@ -408,6 +408,47 @@ public class QuotedStringTokenizer throw new RuntimeException(e); } } + + /* ------------------------------------------------------------ */ + /** Unquote a string, NOT converting unicode sequences + * @param s The string to unquote. + * @return quoted string + */ + public static String unquoteOnly(String s) + { + if (s==null) + return null; + if (s.length()<2) + return s; + + char first=s.charAt(0); + char last=s.charAt(s.length()-1); + if (first!=last || (first!='"' && first!='\'')) + return s; + + StringBuilder b = new StringBuilder(s.length() - 2); + boolean escape=false; + for (int i=1;i