tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r558182 - in /tomcat/trunk/java/org/apache: catalina/manager/host/HTMLHostManagerServlet.java tomcat/util/http/Cookies.java
Date Fri, 20 Jul 2007 22:36:11 GMT
Author: fhanik
Date: Fri Jul 20 15:36:07 2007
New Revision: 558182

URL: http://svn.apache.org/viewvc?view=rev&rev=558182
Log:
upsync from 6.0
http://svn.apache.org/viewvc?view=rev&rev=557454
http://svn.apache.org/viewvc?view=rev&rev=557467 


Modified:
    tomcat/trunk/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java
    tomcat/trunk/java/org/apache/tomcat/util/http/Cookies.java

Modified: tomcat/trunk/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java?view=diff&rev=558182&r1=558181&r2=558182
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java Fri Jul
20 15:36:07 2007
@@ -229,7 +229,8 @@
         for (int i = 0; i < children.length; i++)
             hostNames[i] = children[i].getName();
 
-        TreeMap sortedHostNamesMap = new TreeMap();
+        TreeMap<String,String> sortedHostNamesMap =
+            new TreeMap<String,String>();
 
         for (int i = 0; i < hostNames.length; i++) {
             String displayPath = hostNames[i];
@@ -240,15 +241,16 @@
         String hostsStop = sm.getString("htmlHostManagerServlet.hostsStop");
         String hostsRemove = sm.getString("htmlHostManagerServlet.hostsRemove");
 
-        Iterator iterator = sortedHostNamesMap.entrySet().iterator();
+        Iterator<Map.Entry<String,String>> iterator =
+            sortedHostNamesMap.entrySet().iterator();
         while (iterator.hasNext()) {
-            Map.Entry entry = (Map.Entry) iterator.next();
+            Map.Entry<String,String> 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 @@
 
                 if (buf.length() == 0) {
                     buf.append("&nbsp;");
+                    args[1] = buf.toString();
+                } else {
+                    args[1] = RequestUtil.filter(buf.toString());
                 }
 
-                args[1] = buf.toString();
                 writer.print
                     (MessageFormat.format(HOSTS_ROW_DETAILS_SECTION, args));
 

Modified: tomcat/trunk/java/org/apache/tomcat/util/http/Cookies.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/Cookies.java?view=diff&rev=558182&r1=558181&r2=558182
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/http/Cookies.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/http/Cookies.java Fri Jul 20 15:36:07 2007
@@ -249,9 +249,11 @@
             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 @@
         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 @@
     /**
      *
      * Strips quotes from the start and end of the cookie string
-     * This conforms to RFC 2109
+     * This conforms to RFC 2965
      * 
      * @param value            a <code>String</code> specifying the cookie 
      *                         value (possibly quoted).
@@ -423,8 +423,7 @@
     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) { 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message