2013-06-05 99 views
1

我在我的JSP定义为输入标签:如何从JSP中删除这个XSS?

<input type="text" name="transCurrency" maxlength="10" size="10" value="<%=beanUseVec.getValue("transCurrency")%>" /> 

相应的功能getValue()beanUseVec.java定义为:

public String getValue(String vectK) 
{ 
    if(uEnVec != null && uEnVec.containsKey(vectK)) 
    return (String)uEnVec.get(vectK); 
    else 
    return ""; 
} 

当我做了veracode扫描我的文件,我发现XSS错误如下图所示:

<input type="text" name="transCurrency" maxlength="10" size="10" value="<%=beanUseVec.getValue("transCurrency")%>" /> 

它指出<%=beanUseVec.getValue("transCurrency")%>是XSS风险。通常,对于JSP中的其他XSS风险,我使用jstl c:out标记,我认为这个标记在这里不能使用,因为getValue()不是POJO函数,它只是一个返回字符串的函数,而c:out需要调用POJO函数的变量。

有人可以建议任何其他方式摆脱这个XSS的问题?

回答

1

能省则输出到request变量和使用c:out标签显示它

<% 
String output = beanUseVec.getValue("transCurrency"); 
request.setAttribute("output",output); 
%> 

<input type="text" name="transCurrency" maxlength="10" size="10" value="<c:out value='${output}'/>"/> 
+0

谢谢你让我检查。 –

+0

非常感谢,它像一个魅力.Accepted和投票。 –

+0

我很高兴它帮助:) – vjy