1.
public static String getXSSCheck(String strTemp){
if (strTemp == null || strTemp == "")
return "";
strTemp = replace(strTemp, "#", "#"); //1
strTemp = replace(strTemp, "&", "&"); //2
strTemp = replace(strTemp, "&#35", "#"); // 1번 처리 이후 생긴 &를 2번에서 재수정하여 보정
strTemp = replace(strTemp, "<", "<");
strTemp = replace(strTemp, ">", ">");
strTemp = replace(strTemp, "(", "(");
strTemp = replace(strTemp, ")", ")");
strTemp = replace(strTemp, "\"", """);
strTemp = replace(strTemp, "/", "/");
strTemp = replace(strTemp, "?", "\");
strTemp = replace(strTemp, ":", ";");
strTemp = replace(strTemp, "\n", "
"); //line feed
strTemp = replace(strTemp, "\r", "
"); //carriage return
return strTemp;
}
2.map data 일괄적용
/** * XSS체크 일괄 적용 * @param * @return String */ public static LData getAdjustedXSSData(LData data){ Object[] obj = data.getKeys(); for(int i=0;i < obj.length;i++){ String tmp = (String)obj[i]; data.setString(tmp, StringUtil.getXSSCheck(data.getString(tmp))); } return data; }
댓글 없음:
댓글 쓰기