[OWASP-FILTERS] filters/src/java BaseFilter.java,1.12,1.13

russcoon at users.sourceforge.net russcoon at users.sourceforge.net
Wed Mar 19 12:37:57 EST 2003


Update of /cvsroot/owasp/filters/src/java
In directory sc8-pr-cvs1:/tmp/cvs-serv5642

Modified Files:
	BaseFilter.java 
Log Message:
fixing the borked pattern removal code in BaseFilter.java, adding tests that actually work for both TestBaseFilter and TestFilterStack


Index: BaseFilter.java
===================================================================
RCS file: /cvsroot/owasp/filters/src/java/BaseFilter.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** BaseFilter.java	19 Mar 2003 16:28:44 -0000	1.12
--- BaseFilter.java	19 Mar 2003 17:37:51 -0000	1.13
***************
*** 46,50 ****
  
  	public void ClearValidChars(){
! 		this.goodChars = new Vector();
  	}
  
--- 46,50 ----
  
  	public void ClearValidChars(){
! 		goodChars = new Vector();
  	}
  
***************
*** 53,58 ****
  		// that preserves the granularity
  		this.ClearValidChars();
! 		for(int i=0; i<this.defaultGoodChars.length;i++){
! 			this.AddValidCharExpr(this.defaultGoodChars[i]);
  		}
  	}
--- 53,58 ----
  		// that preserves the granularity
  		this.ClearValidChars();
! 		for(int i=0; i<defaultGoodChars.length;i++){
! 			this.AddValidCharExpr(defaultGoodChars[i]);
  		}
  	}
***************
*** 68,74 ****
  			Pattern tpat = (Pattern)mapEnt.getValue();
  			Matcher tmat = tpat.matcher(this.inputStr);
! 			if(tmat.matches()){
! 				this.inputStr = tmat.replaceAll(this.replacementString);
! 			}
  		}
  
--- 68,76 ----
  			Pattern tpat = (Pattern)mapEnt.getValue();
  			Matcher tmat = tpat.matcher(this.inputStr);
! 			this.inputStr = tmat.replaceAll(this.replacementString);
! 			
! 			// FIXME: why can't the matches() method be relied upon?
! 			// if(tmat.matches()){
! 			// }
  		}
  
***************
*** 77,81 ****
  		// where "abcd" are characters that are acceptable
  
! 		if(this.goodChars.size()>0){
  			String pat = "[^";
  			Iterator vit = goodChars.iterator();
--- 79,83 ----
  		// where "abcd" are characters that are acceptable
  
! 		if(goodChars.size()>0){
  			String pat = "[^";
  			Iterator vit = goodChars.iterator();
***************
*** 110,125 ****
  
  	public void RemoveValidChar(char validChar){
! 		this.goodChars.removeElement(new Character(validChar));
  	}
  
  	public void AddValidCharExpr(String validCharStr){
! 		if(!this.goodChars.contains(validCharStr)){
! 			this.goodChars.add(validCharStr);
  		}
  	}
  
  	public void AddValidChar(char validChar){
! 		if(!this.goodChars.contains(new String(""+validChar))){
! 			this.goodChars.add(new String(""+validChar));
  		}
  	}
--- 112,127 ----
  
  	public void RemoveValidChar(char validChar){
! 		goodChars.removeElement(new Character(validChar));
  	}
  
  	public void AddValidCharExpr(String validCharStr){
! 		if(!goodChars.contains(validCharStr)){
! 			goodChars.add(validCharStr);
  		}
  	}
  
  	public void AddValidChar(char validChar){
! 		if(!goodChars.contains(new String(""+validChar))){
! 			goodChars.add(new String(""+validChar));
  		}
  	}






More information about the Owasp-filters mailing list