You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
package com.util;
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* HTML<EFBFBD><EFBFBD><EFBFBD>Ź<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @author Administrator
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public final class Filter {
|
|
|
|
|
|
|
|
|
|
public Filter(){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public static String escapeHTMLTags( String input ) {
|
|
|
|
|
|
|
|
|
|
if( input == null || input.length() == 0 ) {
|
|
|
|
|
return input;
|
|
|
|
|
}
|
|
|
|
|
StringBuffer buf = new StringBuffer();
|
|
|
|
|
char ch = ' ';
|
|
|
|
|
for( int i=0; i<input.length(); i++ ) {
|
|
|
|
|
ch = input.charAt(i);
|
|
|
|
|
if( ch == '<' ) {
|
|
|
|
|
buf.append( "<" );
|
|
|
|
|
}
|
|
|
|
|
else if( ch == '>' ) {
|
|
|
|
|
buf.append( ">" );
|
|
|
|
|
}
|
|
|
|
|
else if(ch=='&'){
|
|
|
|
|
buf.append("&");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
buf.append( ch );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return buf.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|