【问题标题】:Getting an error in cross site scripting within jsp在jsp中的跨站点脚本中出现错误
【发布时间】:2019-04-30 11:59:49
【问题描述】:

我正在一个项目中遇到跨站脚本错误。在 JSP 文件中,下面有一个代码行

var selSubArea = document.adminForm.subjAreaId.options[document.adminForm.subjAreaId.selectedIndex].text;

任何知道如何解决它的人。任何帮助将不胜感激。 提前致谢

我已经尝试使用不同的编码技术,但没有奏效... 例如。 Encode.forHtml、Encode.forJavascript、COV 安全、fn EscapeXML.....

var selRole = document.adminForm.appnRoleId.options[document.adminForm.appnRoleId.selectedIndex].text;
var selSubArea = document.adminForm.subjAreaId.options[document.adminForm.subjAreaId.selectedIndex].text;
var selRoleID = document.adminForm.appnRoleId.options[document.adminForm.appnRoleId.selectedIndex].value;
var selSubAreaID = document.adminForm.subjAreaId.options[document.adminForm.subjAreaId.selectedIndex].value;

我遇到了这个只有文本输入的跨站点脚本问题。这些实际上是下拉菜单。

【问题讨论】:

    标签: java html jsp


    【解决方案1】:

    我的猜测是您试图阻止有人从您的问题中将数据 XSS 输入到您的下拉菜单中。

    也许在服务器/应用程序上硬编码了所选索引的信息,然后发送索引。

    var selSubArea = document.adminForm.subjAreaId.selectedIndex;
    

    如果索引与服务器/应用程序上的索引不匹配,则忽略它。

    【讨论】:

    • 感谢您的建议..我会尝试使用它..?
    • 嗨,我尝试使用var selSubArea = document.adminForm.subjAreaId.selectedIndex;,但它只提供 ID...有没有其他方法可以同时使用“option”和“SelectedIndex”...
    • 您的 ID 应该与您在服务器上的选项相匹配。你是如何设置服务器端的。它应该采用 Selected 索引并将其与选项匹配
    猜你喜欢
    • 1970-01-01
    • 2021-06-15
    • 1970-01-01
    • 2022-10-06
    • 2012-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-27
    相关资源
    最近更新 更多