You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2006/11/11 22:23:33 UTC

svn commit: r473799 - /tomcat/connectors/trunk/util/java/org/apache/tomcat/util/http/Parameters.java

Author: markt
Date: Sat Nov 11 13:23:32 2006
New Revision: 473799

URL: http://svn.apache.org/viewvc?view=rev&rev=473799
Log:
Tabs -> 8 spaces. No functional change.

Modified:
    tomcat/connectors/trunk/util/java/org/apache/tomcat/util/http/Parameters.java

Modified: tomcat/connectors/trunk/util/java/org/apache/tomcat/util/http/Parameters.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/util/java/org/apache/tomcat/util/http/Parameters.java?view=diff&rev=473799&r1=473798&r2=473799
==============================================================================
--- tomcat/connectors/trunk/util/java/org/apache/tomcat/util/http/Parameters.java (original)
+++ tomcat/connectors/trunk/util/java/org/apache/tomcat/util/http/Parameters.java Sat Nov 11 13:23:32 2006
@@ -69,91 +69,91 @@
      * 
      */
     public Parameters() {
-	super( INITIAL_SIZE );
+        super( INITIAL_SIZE );
     }
 
     public void setQuery( MessageBytes queryMB ) {
-	this.queryMB=queryMB;
+        this.queryMB=queryMB;
     }
 
     public void setHeaders( MimeHeaders headers ) {
-	this.headers=headers;
+        this.headers=headers;
     }
 
     public void setEncoding( String s ) {
-	encoding=s;
-	if(debug>0) log( "Set encoding to " + s );
+        encoding=s;
+        if(debug>0) log( "Set encoding to " + s );
     }
 
     public void setQueryStringEncoding( String s ) {
-	queryStringEncoding=s;
-	if(debug>0) log( "Set query string encoding to " + s );
+        queryStringEncoding=s;
+        if(debug>0) log( "Set query string encoding to " + s );
     }
 
     public void recycle() {
-	super.recycle();
-	paramHashStringArray.clear();
-	didQueryParameters=false;
-	currentChild=null;
-	didMerge=false;
-	encoding=null;
-	decodedQuery.recycle();
+        super.recycle();
+        paramHashStringArray.clear();
+        didQueryParameters=false;
+        currentChild=null;
+        didMerge=false;
+        encoding=null;
+        decodedQuery.recycle();
     }
     
     // -------------------- Sub-request support --------------------
 
     public Parameters getCurrentSet() {
-	if( currentChild==null )
-	    return this;
-	return currentChild;
+        if( currentChild==null )
+            return this;
+        return currentChild;
     }
     
     /** Create ( or reuse ) a child that will be used during a sub-request.
-	All future changes ( setting query string, adding parameters )
-	will affect the child ( the parent request is never changed ).
-	Both setters and getters will return the data from the deepest
-	child, merged with data from parents.
+        All future changes ( setting query string, adding parameters )
+        will affect the child ( the parent request is never changed ).
+        Both setters and getters will return the data from the deepest
+        child, merged with data from parents.
     */
     public void push() {
-	// We maintain a linked list, that will grow to the size of the
-	// longest include chain.
-	// The list has 2 points of interest:
-	// - request.parameters() is the original request and head,
-	// - request.parameters().currentChild() is the current set.
-	// The ->child and parent<- links are preserved ( currentChild is not
-	// the last in the list )
-	
-	// create a new element in the linked list
-	// note that we reuse the child, if any - pop will not
-	// set child to null !
-	if( currentChild==null ) {
-	    currentChild=new Parameters();
-	    currentChild.setURLDecoder( urlDec );
-	    currentChild.parent=this;
-	    return;
-	}
-	if( currentChild.child==null ) {
-	    currentChild.child=new Parameters();
-	    currentChild.setURLDecoder( urlDec );
-	    currentChild.child.parent=currentChild;
-	} // it is not null if this object already had a child
-	// i.e. a deeper include() ( we keep it )
-
-	// the head will be the new element.
-	currentChild=currentChild.child;
-	currentChild.setEncoding( encoding );
+        // We maintain a linked list, that will grow to the size of the
+        // longest include chain.
+        // The list has 2 points of interest:
+        // - request.parameters() is the original request and head,
+        // - request.parameters().currentChild() is the current set.
+        // The ->child and parent<- links are preserved ( currentChild is not
+        // the last in the list )
+        
+        // create a new element in the linked list
+        // note that we reuse the child, if any - pop will not
+        // set child to null !
+        if( currentChild==null ) {
+            currentChild=new Parameters();
+            currentChild.setURLDecoder( urlDec );
+            currentChild.parent=this;
+            return;
+        }
+        if( currentChild.child==null ) {
+            currentChild.child=new Parameters();
+            currentChild.setURLDecoder( urlDec );
+            currentChild.child.parent=currentChild;
+        } // it is not null if this object already had a child
+        // i.e. a deeper include() ( we keep it )
+
+        // the head will be the new element.
+        currentChild=currentChild.child;
+        currentChild.setEncoding( encoding );
     }
 
     /** Discard the last child. This happens when we return from a
-	sub-request and the parameters are locally modified.
+        sub-request and the parameters are locally modified.
      */
     public void pop() {
-	if( currentChild==null ) {
-	    throw new RuntimeException( "Attempt to pop without a push" );
-	}
-	currentChild.recycle();
-	currentChild=currentChild.parent;
-	// don't remove the top.
+        if( currentChild==null ) {
+            throw new RuntimeException( "Attempt to pop without a push" );
+        }
+        currentChild.recycle();
+        currentChild=currentChild.parent;
+        // don't remove the top.
     }
     
     // -------------------- Data access --------------------
@@ -182,80 +182,80 @@
     }
 
     public String[] getParameterValues(String name) {
-	handleQueryParameters();
-	// sub-request
-	if( currentChild!=null ) {
-	    currentChild.merge();
-	    return (String[])currentChild.paramHashStringArray.get(name);
-	}
-
-	// no "facade"
-	String values[]=(String[])paramHashStringArray.get(name);
-	return values;
+        handleQueryParameters();
+        // sub-request
+        if( currentChild!=null ) {
+            currentChild.merge();
+            return (String[])currentChild.paramHashStringArray.get(name);
+        }
+
+        // no "facade"
+        String values[]=(String[])paramHashStringArray.get(name);
+        return values;
     }
  
     public Enumeration getParameterNames() {
-	handleQueryParameters();
-	// Slow - the original code
-	if( currentChild!=null ) {
-	    currentChild.merge();
-	    return currentChild.paramHashStringArray.keys();
-	}
+        handleQueryParameters();
+        // Slow - the original code
+        if( currentChild!=null ) {
+            currentChild.merge();
+            return currentChild.paramHashStringArray.keys();
+        }
 
-	// merge in child
+        // merge in child
         return paramHashStringArray.keys();
     }
 
     /** Combine the parameters from parent with our local ones
      */
     private void merge() {
-	// recursive
-	if( debug > 0 ) {
-	    log("Before merging " + this + " " + parent + " " + didMerge );
-	    log(  paramsAsString());
-	}
-	// Local parameters first - they take precedence as in spec.
-	handleQueryParameters();
-
-	// we already merged with the parent
-	if( didMerge ) return;
-
-	// we are the top level
-	if( parent==null ) return;
-
-	// Add the parent props to the child ( lower precedence )
-	parent.merge();
-	Hashtable parentProps=parent.paramHashStringArray;
-	merge2( paramHashStringArray , parentProps);
-	didMerge=true;
-	if(debug > 0 )
-	    log("After " + paramsAsString());
+        // recursive
+        if( debug > 0 ) {
+            log("Before merging " + this + " " + parent + " " + didMerge );
+            log(  paramsAsString());
+        }
+        // Local parameters first - they take precedence as in spec.
+        handleQueryParameters();
+
+        // we already merged with the parent
+        if( didMerge ) return;
+
+        // we are the top level
+        if( parent==null ) return;
+
+        // Add the parent props to the child ( lower precedence )
+        parent.merge();
+        Hashtable parentProps=parent.paramHashStringArray;
+        merge2( paramHashStringArray , parentProps);
+        didMerge=true;
+        if(debug > 0 )
+            log("After " + paramsAsString());
     }
 
 
     // Shortcut.
     public String getParameter(String name ) {
-	String[] values = getParameterValues(name);
+        String[] values = getParameterValues(name);
         if (values != null) {
-	    if( values.length==0 ) return "";
+            if( values.length==0 ) return "";
             return values[0];
         } else {
-	    return null;
+            return null;
         }
     }
     // -------------------- Processing --------------------
     /** Process the query string into parameters
      */
     public void handleQueryParameters() {
-	if( didQueryParameters ) return;
+        if( didQueryParameters ) return;
 
-	didQueryParameters=true;
+        didQueryParameters=true;
 
-	if( queryMB==null || queryMB.isNull() )
-	    return;
-	
-	if( debug > 0  )
-	    log( "Decoding query " + decodedQuery + " " + queryStringEncoding);
+        if( queryMB==null || queryMB.isNull() )
+            return;
+        
+        if( debug > 0  )
+            log( "Decoding query " + decodedQuery + " " + queryStringEncoding);
 
         try {
             decodedQuery.duplicate( queryMB );
@@ -276,56 +276,56 @@
     private static void merge2(Hashtable one, Hashtable two ) {
         Enumeration e = two.keys();
 
-	while (e.hasMoreElements()) {
-	    String name = (String) e.nextElement();
-	    String[] oneValue = (String[]) one.get(name);
-	    String[] twoValue = (String[]) two.get(name);
-	    String[] combinedValue;
-
-	    if (twoValue == null) {
-		continue;
-	    } else {
-		if( oneValue==null ) {
-		    combinedValue = new String[twoValue.length];
-		    System.arraycopy(twoValue, 0, combinedValue,
-				     0, twoValue.length);
-		} else {
-		    combinedValue = new String[oneValue.length +
-					       twoValue.length];
-		    System.arraycopy(oneValue, 0, combinedValue, 0,
-				     oneValue.length);
-		    System.arraycopy(twoValue, 0, combinedValue,
-				     oneValue.length, twoValue.length);
-		}
-		one.put(name, combinedValue);
-	    }
-	}
+        while (e.hasMoreElements()) {
+            String name = (String) e.nextElement();
+            String[] oneValue = (String[]) one.get(name);
+            String[] twoValue = (String[]) two.get(name);
+            String[] combinedValue;
+
+            if (twoValue == null) {
+                continue;
+            } else {
+                if( oneValue==null ) {
+                    combinedValue = new String[twoValue.length];
+                    System.arraycopy(twoValue, 0, combinedValue,
+                                     0, twoValue.length);
+                } else {
+                    combinedValue = new String[oneValue.length +
+                                               twoValue.length];
+                    System.arraycopy(oneValue, 0, combinedValue, 0,
+                                     oneValue.length);
+                    System.arraycopy(twoValue, 0, combinedValue,
+                                     oneValue.length, twoValue.length);
+                }
+                one.put(name, combinedValue);
+            }
+        }
     }
 
     // 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.
-		get(key);
-	    values = new String[oldValues.length + 1];
-	    for (int i = 0; i < oldValues.length; i++) {
-		values[i] = oldValues[i];
-	    }
-	    values[oldValues.length] = value;
-	} else {
-	    values = new String[1];
-	    values[0] = value;
-	}
-	
-	
-	paramHashStringArray.put(key, values);
+        if( key==null ) return;
+        String values[];
+        if (paramHashStringArray.containsKey(key)) {
+            String oldValues[] = (String[])paramHashStringArray.
+                get(key);
+            values = new String[oldValues.length + 1];
+            for (int i = 0; i < oldValues.length; i++) {
+                values[i] = oldValues[i];
+            }
+            values[oldValues.length] = value;
+        } else {
+            values = new String[1];
+            values[0] = value;
+        }
+        
+        
+        paramHashStringArray.put(key, values);
     }
 
     public void setURLDecoder( UDecoder u ) {
-	urlDec=u;
+        urlDec=u;
     }
 
     // -------------------- Parameter parsing --------------------
@@ -346,47 +346,48 @@
 
     public void processParameters( byte bytes[], int start, int len, 
                                    String enc ) {
-	int end=start+len;
-	int pos=start;
-	
-	if( debug>0 ) 
-	    log( "Bytes: " + new String( bytes, start, len ));
+        int end=start+len;
+        int pos=start;
+        
+        if( debug>0 ) 
+            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, '=' );
-	    // 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 < end) ? nameEnd+1 : end;
-		valEnd=ByteChunk.indexOf(bytes, valStart, end, '&');
-		if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
-	    }
-	    
-	    pos=valEnd+1;
-	    
-	    if( nameEnd<=nameStart ) {
-		continue;
-		// invalid chunk - it's better to ignore
-		// XXX log it ?
-	    }
-	    tmpName.setBytes( bytes, nameStart, nameEnd-nameStart );
-	    tmpValue.setBytes( bytes, valStart, valEnd-valStart );
+            boolean noEq=false;
+            int valStart=-1;
+            int valEnd=-1;
+            
+            int nameStart=pos;
+            int nameEnd=ByteChunk.indexOf(bytes, nameStart, end, '=' );
+            // 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 < end) ? nameEnd+1 : end;
+                valEnd=ByteChunk.indexOf(bytes, valStart, end, '&');
+                if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
+            }
+            
+            pos=valEnd+1;
+            
+            if( nameEnd<=nameStart ) {
+                continue;
+                // invalid chunk - it's better to ignore
+                // XXX log it ?
+            }
+            tmpName.setBytes( bytes, nameStart, nameEnd-nameStart );
+            tmpValue.setBytes( bytes, valStart, valEnd-valStart );
 
             try {
                 addParam( urlDecode(tmpName, enc), urlDecode(tmpValue, enc) );
@@ -394,10 +395,10 @@
                 // Exception during character decoding: skip parameter
             }
 
-	    tmpName.recycle();
-	    tmpValue.recycle();
+            tmpName.recycle();
+            tmpValue.recycle();
 
-	} while( pos<end );
+        } while( pos<end );
     }
 
     private String urlDecode(ByteChunk bc, String enc)
@@ -428,69 +429,70 @@
     }
 
     public void processParameters( char chars[], int start, int len ) {
-	int end=start+len;
-	int pos=start;
-	
-	if( debug>0 ) 
-	    log( "Chars: " + new String( chars, start, len ));
+        int end=start+len;
+        int pos=start;
+        
+        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;
-	    
-	    if( ! noEq ) {
-		valStart= (nameEnd < end) ? nameEnd+1 : end;
-		valEnd=CharChunk.indexOf(chars, valStart, end, '&');
-		if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
-	    }
-	    
-	    pos=valEnd+1;
-	    
-	    if( nameEnd<=nameStart ) {
-		continue;
-		// invalid chunk - no name, it's better to ignore
-		// XXX log it ?
-	    }
-	    
-	    try {
-		tmpNameC.append( chars, nameStart, nameEnd-nameStart );
-		tmpValueC.append( chars, valStart, valEnd-valStart );
-
-		if( debug > 0 )
-		    log( tmpNameC + "= " + tmpValueC);
-
-		if( urlDec==null ) {
-		    urlDec=new UDecoder();   
-		}
-
-		urlDec.convert( tmpNameC );
-		urlDec.convert( tmpValueC );
-
-		if( debug > 0 )
-		    log( tmpNameC + "= " + tmpValueC);
-		
-		addParam( tmpNameC.toString(), tmpValueC.toString() );
-	    } catch( IOException ex ) {
-		ex.printStackTrace();
-	    }
+            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;
+            
+            if( ! noEq ) {
+                valStart= (nameEnd < end) ? nameEnd+1 : end;
+                valEnd=CharChunk.indexOf(chars, valStart, end, '&');
+                if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
+            }
+            
+            pos=valEnd+1;
+            
+            if( nameEnd<=nameStart ) {
+                continue;
+                // invalid chunk - no name, it's better to ignore
+                // XXX log it ?
+            }
+            
+            try {
+                tmpNameC.append( chars, nameStart, nameEnd-nameStart );
+                tmpValueC.append( chars, valStart, valEnd-valStart );
+
+                if( debug > 0 )
+                    log( tmpNameC + "= " + tmpValueC);
+
+                if( urlDec==null ) {
+                    urlDec=new UDecoder();   
+                }
+
+                urlDec.convert( tmpNameC );
+                urlDec.convert( tmpValueC );
+
+                if( debug > 0 )
+                    log( tmpNameC + "= " + tmpValueC);
+                
+                addParam( tmpNameC.toString(), tmpValueC.toString() );
+            } catch( IOException ex ) {
+                ex.printStackTrace();
+            }
 
-	    tmpNameC.recycle();
-	    tmpValueC.recycle();
+            tmpNameC.recycle();
+            tmpValueC.recycle();
 
-	} while( pos<end );
+        } while( pos<end );
     }
     
     public void processParameters( MessageBytes data ) {
@@ -498,35 +500,35 @@
     }
 
     public void processParameters( MessageBytes data, String encoding ) {
-	if( data==null || data.isNull() || data.getLength() <= 0 ) return;
+        if( data==null || data.isNull() || data.getLength() <= 0 ) return;
 
-	if( data.getType() == MessageBytes.T_BYTES ) {
-	    ByteChunk bc=data.getByteChunk();
-	    processParameters( bc.getBytes(), bc.getOffset(),
-			       bc.getLength(), encoding);
-	} else {
-	    if (data.getType()!= MessageBytes.T_CHARS ) 
-		data.toChars();
-	    CharChunk cc=data.getCharChunk();
-	    processParameters( cc.getChars(), cc.getOffset(),
-			       cc.getLength());
-	}
+        if( data.getType() == MessageBytes.T_BYTES ) {
+            ByteChunk bc=data.getByteChunk();
+            processParameters( bc.getBytes(), bc.getOffset(),
+                               bc.getLength(), encoding);
+        } else {
+            if (data.getType()!= MessageBytes.T_CHARS ) 
+                data.toChars();
+            CharChunk cc=data.getCharChunk();
+            processParameters( cc.getChars(), cc.getOffset(),
+                               cc.getLength());
+        }
     }
 
     /** Debug purpose
      */
     public String paramsAsString() {
-	StringBuffer sb=new StringBuffer();
-	Enumeration en= paramHashStringArray.keys();
-	while( en.hasMoreElements() ) {
-	    String k=(String)en.nextElement();
-	    sb.append( k ).append("=");
-	    String v[]=(String[])paramHashStringArray.get( k );
-	    for( int i=0; i<v.length; i++ )
-		sb.append( v[i] ).append(",");
-	    sb.append("\n");
-	}
-	return sb.toString();
+        StringBuffer sb=new StringBuffer();
+        Enumeration en= paramHashStringArray.keys();
+        while( en.hasMoreElements() ) {
+            String k=(String)en.nextElement();
+            sb.append( k ).append("=");
+            String v[]=(String[])paramHashStringArray.get( k );
+            for( int i=0; i<v.length; i++ )
+                sb.append( v[i] ).append(",");
+            sb.append("\n");
+        }
+        return sb.toString();
     }
 
     private static int debug=0;
@@ -540,72 +542,73 @@
     /** Used by RequestDispatcher
      */
     public void processParameters( String str ) {
-	int end=str.length();
-	int pos=0;
-	if( debug > 0)
-	    log("String: " + str );
-	
+        int end=str.length();
+        int pos=0;
+        if( debug > 0)
+            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;
-
-	    if( ! noEq ) {
-		valStart=nameEnd+1;
-		valEnd=str.indexOf('&', valStart);
-		if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
-	    }
-	    
-	    pos=valEnd+1;
-	    
-	    if( nameEnd<=nameStart ) {
-		continue;
-	    }
-	    if( debug>0)
-		log( "XXX " + nameStart + " " + nameEnd + " "
-		     + valStart + " " + valEnd );
-	    
-	    try {
-		tmpNameC.append(str, nameStart, nameEnd-nameStart );
-		tmpValueC.append(str, valStart, valEnd-valStart );
-	    
-		if( debug > 0 )
-		    log( tmpNameC + "= " + tmpValueC);
-
-		if( urlDec==null ) {
-		    urlDec=new UDecoder();   
-		}
-
-		urlDec.convert( tmpNameC );
-		urlDec.convert( tmpValueC );
-
-		if( debug > 0 )
-		    log( tmpNameC + "= " + tmpValueC);
-		
-		addParam( tmpNameC.toString(), tmpValueC.toString() );
-	    } catch( IOException ex ) {
-		ex.printStackTrace();
-	    }
+            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;
+
+            if( ! noEq ) {
+                valStart=nameEnd+1;
+                valEnd=str.indexOf('&', valStart);
+                if( valEnd== -1 ) valEnd = (valStart < end) ? end : valStart;
+            }
+            
+            pos=valEnd+1;
+            
+            if( nameEnd<=nameStart ) {
+                continue;
+            }
+            if( debug>0)
+                log( "XXX " + nameStart + " " + nameEnd + " "
+                     + valStart + " " + valEnd );
+            
+            try {
+                tmpNameC.append(str, nameStart, nameEnd-nameStart );
+                tmpValueC.append(str, valStart, valEnd-valStart );
+            
+                if( debug > 0 )
+                    log( tmpNameC + "= " + tmpValueC);
+
+                if( urlDec==null ) {
+                    urlDec=new UDecoder();   
+                }
+
+                urlDec.convert( tmpNameC );
+                urlDec.convert( tmpValueC );
+
+                if( debug > 0 )
+                    log( tmpNameC + "= " + tmpValueC);
+                
+                addParam( tmpNameC.toString(), tmpValueC.toString() );
+            } catch( IOException ex ) {
+                ex.printStackTrace();
+            }
 
-	    tmpNameC.recycle();
-	    tmpValueC.recycle();
+            tmpNameC.recycle();
+            tmpValueC.recycle();
 
-	} while( pos<end );
+        } while( pos<end );
     }
 
 



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