Skip to content

Commit c2adc5f

Browse files
author
planetlevel
committed
replace control characters with a space instead of deleting
1 parent 4763f5e commit c2adc5f

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/org/owasp/esapi/StringUtilities.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,20 @@
2727
public class StringUtilities {
2828

2929
/**
30-
* Removes all unprintable characters from a string for use in an HTTP header
30+
* Removes all unprintable characters from a string
31+
* and replaces with a space for use in an HTTP header
3132
* @param input
3233
* @return the stripped header
3334
*/
3435
public static String stripControls( String input ) {
3536
StringBuffer sb = new StringBuffer();
3637
for ( int i=0; i<input.length(); i++ ) {
3738
char c = input.charAt( i );
38-
if ( c > 0x20 && c < 0x7f ) sb.append( c );
39+
if ( c > 0x20 && c < 0x7f ) {
40+
sb.append( c );
41+
} else {
42+
sb.append( ' ' );
43+
}
3944
}
4045
return sb.toString();
4146
}

0 commit comments

Comments
 (0)