From 8797c74cfec6d238afee737d5fdedbbcaffb3cca Mon Sep 17 00:00:00 2001 From: fhanik Date: Fri, 20 Jul 2007 22:36:07 +0000 Subject: [PATCH] upsync from 6.0 http://svn.apache.org/viewvc?view=rev&rev=557454 http://svn.apache.org/viewvc?view=rev&rev=557467 git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@558182 13f79535-47bb-0310-9956-ffa450edef68 --- .../manager/host/HTMLHostManagerServlet.java | 14 +++++--- java/org/apache/tomcat/util/http/Cookies.java | 39 +++++++++++----------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java b/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java index 55fc94bea..e6a8ee5d3 100644 --- a/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java +++ b/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java @@ -229,7 +229,8 @@ public final class HTMLHostManagerServlet extends HostManagerServlet { for (int i = 0; i < children.length; i++) hostNames[i] = children[i].getName(); - TreeMap sortedHostNamesMap = new TreeMap(); + TreeMap sortedHostNamesMap = + new TreeMap(); for (int i = 0; i < hostNames.length; i++) { String displayPath = hostNames[i]; @@ -240,15 +241,16 @@ public final class HTMLHostManagerServlet extends HostManagerServlet { String hostsStop = sm.getString("htmlHostManagerServlet.hostsStop"); String hostsRemove = sm.getString("htmlHostManagerServlet.hostsRemove"); - Iterator iterator = sortedHostNamesMap.entrySet().iterator(); + Iterator> iterator = + sortedHostNamesMap.entrySet().iterator(); while (iterator.hasNext()) { - Map.Entry entry = (Map.Entry) iterator.next(); + Map.Entry entry = iterator.next(); String hostName = (String) entry.getKey(); Host host = (Host) engine.findChild(hostName); if (host != null ) { args = new Object[2]; - args[0] = hostName; + args[0] = RequestUtil.filter(hostName); String[] aliases = host.findAliases(); StringBuffer buf = new StringBuffer(); if (aliases.length > 0) { @@ -260,9 +262,11 @@ public final class HTMLHostManagerServlet extends HostManagerServlet { if (buf.length() == 0) { buf.append(" "); + args[1] = buf.toString(); + } else { + args[1] = RequestUtil.filter(buf.toString()); } - args[1] = buf.toString(); writer.print (MessageFormat.format(HOSTS_ROW_DETAILS_SECTION, args)); diff --git a/java/org/apache/tomcat/util/http/Cookies.java b/java/org/apache/tomcat/util/http/Cookies.java index 89e58b0b5..a1f451492 100644 --- a/java/org/apache/tomcat/util/http/Cookies.java +++ b/java/org/apache/tomcat/util/http/Cookies.java @@ -249,9 +249,11 @@ public final class Cookies { // extends MultiMap { int endValue=startValue; cc=bytes[pos]; - if( cc== '\'' || cc=='"' ) { - startValue++; - endValue=indexOf( bytes, startValue, end, cc ); + if( cc=='"' ) { + endValue=findDelim3( bytes, startValue+1, end, cc ); + if (endValue == -1) { + endValue=findDelim2( bytes, startValue+1, end ); + } else startValue++; pos=endValue+1; // to skip to next cookie } else { endValue=findDelim2( bytes, startValue, end ); @@ -335,28 +337,26 @@ public final class Cookies { // extends MultiMap { return off; } - public static int indexOf( byte bytes[], int off, int end, byte qq ) + /* + * search for cc but skip \cc as required by rfc2616 + * (according to rfc2616 cc should be ") + */ + public static int findDelim3( byte bytes[], int off, int end, byte cc ) { while( off < end ) { byte b=bytes[off]; - if( b==qq ) + if ( b== '\\' ) { + off++; + off++; + continue; + } + if( b==cc ) return off; off++; } - return off; + return -1; } - public static int indexOf( byte bytes[], int off, int end, char qq ) - { - while( off < end ) { - byte b=bytes[off]; - if( b==qq ) - return off; - off++; - } - return off; - } - // XXX will be refactored soon! public static boolean equals( String s, byte b[], int start, int end) { int blen = end-start; @@ -412,7 +412,7 @@ public final class Cookies { // extends MultiMap { /** * * Strips quotes from the start and end of the cookie string - * This conforms to RFC 2109 + * This conforms to RFC 2965 * * @param value a String specifying the cookie * value (possibly quoted). @@ -423,8 +423,7 @@ public final class Cookies { // extends MultiMap { private static String stripQuote( String value ) { // log("Strip quote from " + value ); - if (((value.startsWith("\"")) && (value.endsWith("\""))) || - ((value.startsWith("'") && (value.endsWith("'"))))) { + if (value.startsWith("\"") && value.endsWith("\"")) { try { return value.substring(1,value.length()-1); } catch (Exception ex) { -- 2.11.0