Jquery 如何修复此代码中的XSS漏洞?
这是我的搜索功能Jquery 如何修复此代码中的XSS漏洞?,jquery,xss,Jquery,Xss,这是我的搜索功能 $('#productSearch').live('focus',function(){ $(this).stop().animate({'width':'200px'}, 600); var searchterm = encodeURIComponent($('#productSearch').val()); if (searchterm != '') { $('.ajax-search-results').show();
$('#productSearch').live('focus',function(){
$(this).stop().animate({'width':'200px'}, 600);
var searchterm = encodeURIComponent($('#productSearch').val());
if (searchterm != '') {
$('.ajax-search-results').show();
$('.ajax-search-results').load('<?php echo get_template_directory_uri(); ?>/ajax/search.php?type=product&s=' + searchterm);
}
});
$('productSearch').live('focus',function(){
$(this.stop().animate({'width':'200px'},600);
var searchterm=encodeURIComponent($('#productSearch').val());
如果(搜索术语!=''){
$('.ajax搜索结果').show();
$('.ajax搜索结果').load('/ajax/search.php?type=product&s='+searchterm);
}
});
我刚刚收到警报,它包含XSS漏洞,但我不知道如何修复它,或者它驻留在哪里
有人能解释一下吗?您可以使用变量searcterm遵循以下规则:
在我自己的代码中,我不明白问题出在哪里?我真的迷路了,是谁给我的?你的代码看起来不错。我想说,在PHP中如何处理这些数据是一个问题。