tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http Cookies.java MimeHeaders.java Parameters.java ServerCookie.java
Date Mon, 31 Dec 2001 18:20:05 GMT
costin      01/12/31 10:20:05

  Modified:    util/java/org/apache/tomcat/util/buf Base64.java
                        ByteChunk.java DateTool.java HexUtils.java
                        MessageBytes.java TimeStamp.java UDecoder.java
                        UEncoder.java
               util/java/org/apache/tomcat/util/collections LRUCache.java
                        SimpleHashtable.java SimplePool.java
               util/java/org/apache/tomcat/util/http Cookies.java
                        MimeHeaders.java Parameters.java ServerCookie.java
  Log:
  Synchronize utils with 3.3 release.
  
  Revision  Changes    Path
  1.2       +1 -5      jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/Base64.java
  
  Index: Base64.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/Base64.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Base64.java	16 May 2001 23:17:55 -0000	1.1
  +++ Base64.java	31 Dec 2001 18:20:04 -0000	1.2
  @@ -1,8 +1,4 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/Base64.java,v
1.1 2001/05/16 23:17:55 seguin Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/05/16 23:17:55 $
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -74,7 +70,7 @@
    * This class is used by XML Schema binary format validation
    *
    * @author Jeffrey Rodriguez
  - * @version $Revision: 1.1 $ $Date: 2001/05/16 23:17:55 $
  + * @version $Revision: 1.2 $ $Date: 2001/12/31 18:20:04 $
    */
   
   public final class Base64 {
  
  
  
  1.5       +1 -1      jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ByteChunk.java	20 Jun 2001 05:24:47 -0000	1.4
  +++ ByteChunk.java	31 Dec 2001 18:20:04 -0000	1.5
  @@ -586,7 +586,7 @@
   	}
   	return -1;
       }
  -    
  +
       // -------------------- Hash code  --------------------
   
       // normal hash. 
  
  
  
  1.4       +41 -24    jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/DateTool.java
  
  Index: DateTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/DateTool.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DateTool.java	9 Jun 2001 00:12:51 -0000	1.3
  +++ DateTool.java	31 Dec 2001 18:20:04 -0000	1.4
  @@ -84,19 +84,19 @@
   
       /** GMT timezone - all HTTP dates are on GMT
        */
  -    private final static TimeZone GMT_ZONE = TimeZone.getTimeZone("GMT");
  +    public final static TimeZone GMT_ZONE = TimeZone.getTimeZone("GMT");
   
       /** format for RFC 1123 date string -- "Sun, 06 Nov 1994 08:49:37 GMT"
        */
  -    private final static String RFC1123_PATTERN =
  +    public final static String RFC1123_PATTERN =
           "EEE, dd MMM yyyy HH:mm:ss z";
   
       // format for RFC 1036 date string -- "Sunday, 06-Nov-94 08:49:37 GMT"
  -    private final static String rfc1036Pattern =
  +    public final static String rfc1036Pattern =
           "EEEEEEEEE, dd-MMM-yy HH:mm:ss z";
   
       // format for C asctime() date string -- "Sun Nov  6 08:49:37 1994"
  -    private final static String asctimePattern =
  +    public final static String asctimePattern =
           "EEE MMM d HH:mm:ss yyyy";
   
       /** Pattern used for old cookies
  @@ -127,6 +127,9 @@
   	asctimeFormat.setTimeZone(GMT_ZONE);
       }
    
  +    private static String rfc1123DS;
  +    private static long   rfc1123Sec;
  +
       private static StringManager sm =
           StringManager.getManager("org.apache.tomcat.util.buf.res");
   
  @@ -139,7 +142,21 @@
       /** 
        */
       public static String format1123( Date d ) {
  -	return rfc1123Format.format( d );
  +        long dt = d.getTime() % 1000;
  +        if ((rfc1123DS != null) && (dt == rfc1123Sec))
  +            return rfc1123DS;
  +        rfc1123DS  = rfc1123Format.format( d );
  +        rfc1123Sec = dt;
  +        return rfc1123DS;
  +    } 
  +
  +    public static String format1123( Date d,DateFormat df ) {
  +        long dt = d.getTime() % 1000;
  +        if ((rfc1123DS != null) && (dt == rfc1123Sec))
  +            return rfc1123DS;
  +        rfc1123DS  = df.format( d );
  +        rfc1123Sec = dt;
  +        return rfc1123DS;
       } 
   
   
  @@ -149,13 +166,19 @@
       public static void formatOldCookie( Date d, StringBuffer sb,
   					  FieldPosition fp )
       {
  -	oldCookieFormat.format( d, sb, fp );
  +	synchronized(oldCookieFormat) {
  +	    oldCookieFormat.format( d, sb, fp );
  +	}
       }
   
       // Called from ServerCookie
       public static String formatOldCookie( Date d )
       {
  -	return oldCookieFormat.format( d );
  +	String ocf=null;
  +	synchronized(oldCookieFormat) {
  +	    ocf= oldCookieFormat.format( d );
  +	}
  +	return ocf;
       }
   
       
  @@ -163,24 +186,18 @@
   	Not efficient - but not very used.
        */
       public static long parseDate( String dateString ) {
  +	DateFormat [] format = {rfc1123Format,rfc1036Format,asctimeFormat};
  +	return parseDate(dateString,format);
  +    }
  +    public static long parseDate( String dateString, DateFormat []format ) {
   	Date date=null;
  -        try {
  -            date = DateTool.rfc1123Format.parse(dateString);
  -	    return date.getTime();
  -	} catch (ParseException e) { }
  -          catch (StringIndexOutOfBoundsException e) { }
  -	
  -        try {
  -	    date = DateTool.rfc1036Format.parse(dateString);
  -	    return date.getTime();
  -	} catch (ParseException e) { }
  -          catch (StringIndexOutOfBoundsException e) { }
  -	
  -        try {
  -            date = DateTool.asctimeFormat.parse(dateString);
  -	    return date.getTime();
  -        } catch (ParseException pe) { }
  -          catch (StringIndexOutOfBoundsException e) { }
  +	for(int i=0; i < format.length; i++) {
  +	    try {
  +		date = format[i].parse(dateString);
  +		return date.getTime();
  +	    } catch (ParseException e) { }
  +	    catch (StringIndexOutOfBoundsException e) { }
  +	}
   	String msg = sm.getString("httpDate.pe", dateString);
   	throw new IllegalArgumentException(msg);
       }
  
  
  
  1.4       +0 -4      jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/HexUtils.java
  
  Index: HexUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/HexUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HexUtils.java	9 Jun 2001 00:12:51 -0000	1.3
  +++ HexUtils.java	31 Dec 2001 18:20:04 -0000	1.4
  @@ -1,8 +1,4 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/HexUtils.java,v
1.3 2001/06/09 00:12:51 costin Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/06/09 00:12:51 $
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  
  
  
  1.6       +30 -3     jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/MessageBytes.java
  
  Index: MessageBytes.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/MessageBytes.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MessageBytes.java	21 Jun 2001 21:22:09 -0000	1.5
  +++ MessageBytes.java	31 Dec 2001 18:20:04 -0000	1.6
  @@ -99,6 +99,10 @@
       public MessageBytes() {
       }
   
  +    public static MessageBytes newInstance() {
  +	return factory.newInstance();
  +    }
  +    
       public void setCaseSenitive( boolean b ) {
   	caseSensitive=b;
       }
  @@ -499,21 +503,29 @@
       
       /**
        *  @deprecated The buffer are general purpose, caching for headers should
  -     *  be done in headers
  +     *  be done in headers. The second parameter allows us to pass a date format
  +     * instance to avoid synchronization problems.
        */
  -    public void setTime(long t) {
  +    public void setTime(long t, DateFormat df) {
   	// XXX replace it with a byte[] tool
   	recycle();
   	if( dateValue==null)
   	    dateValue=new Date(t);
   	else
   	    dateValue.setTime(t);
  -	strValue=DateTool.format1123(dateValue);
  +	if( df==null )
  +	    strValue=DateTool.format1123(dateValue);
  +	else
  +	    strValue=DateTool.format1123(dateValue,df);
   	hasStrValue=true;
   	hasDateValue=true;
   	type=T_STR;   
       }
   
  +    public void setTime(long t) {
  +	setTime( t, null );
  +    }
  +
       /** Set the buffer to the representation of an int
        *  @deprecated The buffer are general purpose, caching for headers should
        *  be done in headers
  @@ -570,5 +582,20 @@
   	hasIntValue=true;
   	return intValue;
       }
  +
  +    // -------------------- Future may be different --------------------
  +    
  +    private static MessageBytesFactory factory=new MessageBytesFactory();
  +
  +    public static void setFactory( MessageBytesFactory mbf ) {
  +	factory=mbf;
  +    }
       
  +    public static class MessageBytesFactory {
  +	protected MessageBytesFactory() {
  +	}
  +	public MessageBytes newInstance() {
  +	    return new MessageBytes();
  +	}
  +    }
   }
  
  
  
  1.3       +1 -1      jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/TimeStamp.java
  
  Index: TimeStamp.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/TimeStamp.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TimeStamp.java	29 May 2001 06:22:53 -0000	1.2
  +++ TimeStamp.java	31 Dec 2001 18:20:04 -0000	1.3
  @@ -115,7 +115,7 @@
        *  The name is a MessageBytes - i.e. a modifiable byte[] or char[]. 
        */
       public MessageBytes getName() {
  -	if( name==null ) name=new MessageBytes();//lazy
  +	if( name==null ) name=MessageBytes.newInstance();//lazy
   	return name;
       }
   
  
  
  
  1.4       +1 -0      jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/UDecoder.java
  
  Index: UDecoder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/UDecoder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- UDecoder.java	20 Jun 2001 05:24:47 -0000	1.3
  +++ UDecoder.java	31 Dec 2001 18:20:04 -0000	1.4
  @@ -143,6 +143,7 @@
   	}
   	
   	if( idx2 >= 0 && idx2 < idx ) idx=idx2; 
  +	if( idx < 0 ) idx=idx2;
   
   	for( int j=idx; j<cend; j++, idx++ ) {
   	    if( buff[ j ] == '+' ) {
  
  
  
  1.2       +18 -2     jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/UEncoder.java
  
  Index: UEncoder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/buf/UEncoder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UEncoder.java	29 May 2001 06:22:53 -0000	1.1
  +++ UEncoder.java	31 Dec 2001 18:20:04 -0000	1.2
  @@ -158,8 +158,24 @@
   	    buf.write(ch);
   	}
       }
  -
  -
  +    
  +    /**
  +     * Utility funtion to re-encode the URL.
  +     * Still has problems with charset, since UEncoder mostly
  +     * ignores it.
  +     */
  +    public String encodeURL(String uri) {
  +	String outUri=null;
  +	try {
  +	    // XXX optimize - recycle, etc
  +	    CharArrayWriter out = new CharArrayWriter();
  +	    urlEncode(out, uri);
  +	    outUri=out.toString();
  +	} catch (IOException iex) {
  +	}
  +	return outUri;
  +    }
  +    
   
       // -------------------- Internal implementation --------------------
       
  
  
  
  1.2       +0 -4      jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/collections/LRUCache.java
  
  Index: LRUCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/collections/LRUCache.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LRUCache.java	16 May 2001 23:18:02 -0000	1.1
  +++ LRUCache.java	31 Dec 2001 18:20:04 -0000	1.2
  @@ -1,8 +1,4 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/collections/LRUCache.java,v
1.1 2001/05/16 23:18:02 seguin Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/05/16 23:18:02 $
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  
  
  
  1.2       +18 -5     jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/collections/SimpleHashtable.java
  
  Index: SimpleHashtable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/collections/SimpleHashtable.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimpleHashtable.java	16 May 2001 23:18:05 -0000	1.1
  +++ SimpleHashtable.java	31 Dec 2001 18:20:04 -0000	1.2
  @@ -97,7 +97,6 @@
    * it makes a significant difference when normalizing attributes,
    * which is done for each start-element construct.
    *
  - * @version $Revision: 1.1 $
    */
   public final class SimpleHashtable implements Enumeration
   {
  @@ -108,6 +107,7 @@
       private Entry		current = null;
       private int			currentBucket = 0;
   
  +    // number of elements in hashtable
       private int			count;
       private int			threshold;
   
  @@ -166,6 +166,7 @@
       public Enumeration keys() {
   	currentBucket = 0;
   	current = null;
  +	hasMoreElements();
   	return this;
       }
   
  @@ -197,6 +198,9 @@
   	    throw new IllegalStateException ();
   	retval = current.key;
   	current = current.next;
  +	// Advance to the next position ( we may call next after next,
  +	// without hasMore )
  +	hasMoreElements();
   	return retval;
       }
   
  @@ -313,18 +317,22 @@
   	Entry prev=null;
   	int hash = key.hashCode();
   	int index = (hash & 0x7FFFFFFF) % tab.length;
  +	if( dL > 0 ) d("Idx " + index +  " " + tab[index] );
   	for (Entry e = tab[index] ; e != null ; prev=e, e = e.next) {
  +	    if( dL > 0 ) d("> " + prev + " " + e.next + " " + e + " " + e.key);
   	    if ((e.hash == hash) && e.key.equals(key)) {
   		if( prev!=null ) {
   		    prev.next=e.next;
   		} else {
   		    tab[index]=e.next;
   		}
  +		if( dL > 0 ) d("Removing from list " + tab[index] + " " + prev +
  +			       " " + e.value);
  +		count--;
  +		Object res=e.value;
  +		e.value=null;
  +		return res;
   	    }
  -	    count--;
  -	    Object res=e.value;
  -	    e.value=null;
  -	    return res;
   	}
   	return null;
       }
  @@ -344,5 +352,10 @@
   	    this.value = value;
   	    this.next = next;
   	}
  +    }
  +
  +    private static final int dL=0;
  +    private void d(String s ) {
  +	System.err.println( "SimpleHashtable: " + s );
       }
   }
  
  
  
  1.2       +1 -0      jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/collections/SimplePool.java
  
  Index: SimplePool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/collections/SimplePool.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimplePool.java	16 May 2001 23:18:05 -0000	1.1
  +++ SimplePool.java	31 Dec 2001 18:20:04 -0000	1.2
  @@ -131,6 +131,7 @@
   	synchronized( lock ) {
   	    if( current >= 0 ) {
   		item = pool[current];
  +		pool[current] = null;
   		current -= 1;
   	    }
   	    if( debug > 0 ) 
  
  
  
  1.2       +1 -1      jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Cookies.java
  
  Index: Cookies.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Cookies.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Cookies.java	16 May 2001 23:18:10 -0000	1.1
  +++ Cookies.java	31 Dec 2001 18:20:05 -0000	1.2
  @@ -357,7 +357,7 @@
       {
   	while( off < end ) {
   	    byte b=bytes[off];
  -	    if( b==' ' || b==';' || b==',' )
  +	    if( b==';' || b==',' )
   		return off;
   	    off++;
   	}
  
  
  
  1.2       +2 -2      jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/MimeHeaders.java
  
  Index: MimeHeaders.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/MimeHeaders.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MimeHeaders.java	16 May 2001 23:18:12 -0000	1.1
  +++ MimeHeaders.java	31 Dec 2001 18:20:05 -0000	1.2
  @@ -451,8 +451,8 @@
       MimeHeaderField next;
       MimeHeaderField prev; 
       
  -    protected final MessageBytes nameB = new MessageBytes();
  -    protected final MessageBytes valueB = new MessageBytes();
  +    protected final MessageBytes nameB = MessageBytes.newInstance();
  +    protected final MessageBytes valueB = MessageBytes.newInstance();
   
       /**
        * Creates a new, uninitialized header field.
  
  
  
  1.6       +67 -15    jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Parameters.java
  
  Index: Parameters.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/Parameters.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Parameters.java	21 Jun 2001 04:38:13 -0000	1.5
  +++ Parameters.java	31 Dec 2001 18:20:05 -0000	1.6
  @@ -82,7 +82,7 @@
       MimeHeaders  headers;
   
       UDecoder urlDec;
  -    MessageBytes decodedQuery=new MessageBytes();
  +    MessageBytes decodedQuery=MessageBytes.newInstance();
       
       public static final int INITIAL_SIZE=4;
   
  @@ -317,6 +317,7 @@
       // incredibly inefficient data representation for parameters,
       // until we test the new one
       private void addParam( String key, String value ) {
  +	if( key==null ) return;
   	String values[];
   	if (paramHashStringArray.containsKey(key)) {
   	    String oldValues[] = (String[])paramHashStringArray.
  @@ -359,13 +360,30 @@
   	    log( "Bytes: " + new String( bytes, start, len ));
   
           do {
  +	    boolean noEq=false;
  +	    int valStart=-1;
  +	    int valEnd=-1;
  +	    
   	    int nameStart=pos;
   	    int nameEnd=ByteChunk.indexOf(bytes, nameStart, end, '=' );
  -	    if( nameEnd== -1 ) nameEnd=end;
  -	    
  -	    int valStart=nameEnd+1;
  -	    int valEnd=ByteChunk.indexOf(bytes, valStart, end, '&');
  -	    if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
  +	    // Workaround for a&b&c encoding
  +	    int nameEnd2=ByteChunk.indexOf(bytes, nameStart, end, '&' );
  +	    if( (nameEnd2!=-1 ) &&
  +		( nameEnd==-1 || nameEnd > nameEnd2) ) {
  +		nameEnd=nameEnd2;
  +		noEq=true;
  +		valStart=nameEnd;
  +		valEnd=nameEnd;
  +		if( debug>0) log("no equal " + nameStart + " " + nameEnd + " " + new String(bytes,
nameStart, nameEnd-nameStart) );
  +	    }
  +	    if( nameEnd== -1 ) 
  +		nameEnd=end;
  +
  +	    if( ! noEq ) {
  +		valStart=nameEnd+1;
  +		valEnd=ByteChunk.indexOf(bytes, valStart, end, '&');
  +		if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
  +	    }
   	    
   	    pos=valEnd+1;
   	    
  @@ -381,7 +399,7 @@
   	    
   	    try {
   		if( debug > 0 )
  -		    log( tmpName + "= " + tmpValue);
  +		    log( "Found " + tmpName + "= " + tmpValue);
   
   		if( urlDec==null ) {
   		    urlDec=new UDecoder();   
  @@ -390,7 +408,7 @@
   		urlDec.convert( tmpValue );
   
   		if( debug > 0 )
  -		    log( tmpName + "= " + tmpValue);
  +		    log( "After url decoding " + tmpName + "= " + tmpValue);
   		
   		addParam( tmpName.toString(), tmpValue.toString() );
   	    } catch( IOException ex ) {
  @@ -410,13 +428,29 @@
   	if( debug>0 ) 
   	    log( "Chars: " + new String( chars, start, len ));
           do {
  +	    boolean noEq=false;
   	    int nameStart=pos;
  +	    int valStart=-1;
  +	    int valEnd=-1;
  +	    
   	    int nameEnd=CharChunk.indexOf(chars, nameStart, end, '=' );
  +	    int nameEnd2=CharChunk.indexOf(chars, nameStart, end, '&' );
  +	    if( (nameEnd2!=-1 ) &&
  +		( nameEnd==-1 || nameEnd > nameEnd2) ) {
  +		nameEnd=nameEnd2;
  +		noEq=true;
  +		valStart=nameEnd;
  +		valEnd=nameEnd;
  +		if( debug>0) log("no equal " + nameStart + " " + nameEnd + " " + new String(chars,
nameStart, nameEnd-nameStart) );
  +	    }
   	    if( nameEnd== -1 ) nameEnd=end;
  -
  -	    int valStart=nameEnd+1;
  -	    int valEnd=CharChunk.indexOf(chars, valStart, end, '&');
  -	    if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
  +	    
  +	    if( ! noEq ) {
  +		valStart=nameEnd+1;
  +		valEnd=CharChunk.indexOf(chars, valStart, end, '&');
  +		if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
  +	    }
  +	    
   	    pos=valEnd+1;
   	    
   	    if( nameEnd<=nameStart ) {
  @@ -501,13 +535,31 @@
   	    log("String: " + str );
   	
           do {
  +	    boolean noEq=false;
  +	    int valStart=-1;
  +	    int valEnd=-1;
  +	    
   	    int nameStart=pos;
   	    int nameEnd=str.indexOf('=', nameStart );
  +	    int nameEnd2=str.indexOf('&', nameStart );
  +	    if( nameEnd2== -1 ) nameEnd2=end;
  +	    if( (nameEnd2!=-1 ) &&
  +		( nameEnd==-1 || nameEnd > nameEnd2) ) {
  +		nameEnd=nameEnd2;
  +		noEq=true;
  +		valStart=nameEnd;
  +		valEnd=nameEnd;
  +		if( debug>0) log("no equal " + nameStart + " " + nameEnd + " " + str.substring(nameStart,
nameEnd) );
  +	    }
  +
   	    if( nameEnd== -1 ) nameEnd=end;
   
  -	    int valStart=nameEnd+1;
  -	    int valEnd=str.indexOf('&', valStart);
  -	    if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
  +	    if( ! noEq ) {
  +		valStart=nameEnd+1;
  +		valEnd=str.indexOf('&', valStart);
  +		if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
  +	    }
  +	    
   	    pos=valEnd+1;
   	    
   	    if( nameEnd<=nameStart ) {
  
  
  
  1.3       +5 -5      jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/ServerCookie.java
  
  Index: ServerCookie.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http/ServerCookie.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServerCookie.java	29 May 2001 06:22:54 -0000	1.2
  +++ ServerCookie.java	31 Dec 2001 18:20:05 -0000	1.3
  @@ -72,16 +72,16 @@
    *  and the facade will convert it to the external representation.
    */
   public class ServerCookie implements Serializable {
  -    private MessageBytes name=new MessageBytes();
  -    private MessageBytes value=new MessageBytes();
  +    private MessageBytes name=MessageBytes.newInstance();
  +    private MessageBytes value=MessageBytes.newInstance();
   
  -    private MessageBytes comment=new MessageBytes();    // ;Comment=VALUE
  -    private MessageBytes domain=new MessageBytes();    // ;Domain=VALUE ...
  +    private MessageBytes comment=MessageBytes.newInstance();    // ;Comment=VALUE
  +    private MessageBytes domain=MessageBytes.newInstance();    // ;Domain=VALUE ...
   
       private int maxAge = -1;	// ;Max-Age=VALUE
   				// ;Discard ... implied by maxAge < 0
       // RFC2109: maxAge=0 will end a session
  -    private MessageBytes path=new MessageBytes();	// ;Path=VALUE .
  +    private MessageBytes path=MessageBytes.newInstance();	// ;Path=VALUE .
       private boolean secure;	// ;Secure
       private int version = 0;	// ;Version=1
   
  
  
  

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


Mime
View raw message