在通过火车头向DiscuzX论坛发布文章时,出现错误“您当前的访问请求当中含有非法字符,已经被系统拒绝”。
解决方法是禁用Discuz的全局安全检查,但会引发一些不安全的恶意攻击,因此在发布之后改回原样。
方案1
则可以修改DiscuzX的配置文件 config/config_global.php,禁用安全检查:
$_config['security']['urlxssdefend'] = '1';修改为:
$_config['security']['urlxssdefend'] = 0;方案2
打开:
\source\class\discuz的discuz_application.php查找
private function _xss_check() {static ParseError: KaTeX parse error: Can't use function '\'' in math mode at position 31: …"', '>', '<', '\̲'̲', '(', ')', 'C…
if(isset(_GET['formhash']) &&
if(_SERVER['REQUEST_METHOD'] == 'GET' ) {
_SERVER['REQUEST_URI'];
} elseif(empty (ParseError: KaTeX parse error: Expected '}', got 'EOF' at end of input: …'formhash'])) {temp = ParseError: KaTeX parse error: Expected 'EOF', got '}' at position 66: …put'); }̲ else {temp = '';
}if(!empty(ParseError: KaTeX parse error: Expected '}', got 'EOF' at end of input: temp)) {temp = strtoupper(urldecode(urldecode(check as ParseError: KaTeX parse error: Expected '}', got 'EOF' at end of input: … if(strpos(temp, $str) !== false) {
system_error('request_tainting');
}
}
}return true;
}修改为:
/**private function _xss_check() {
static ParseError: KaTeX parse error: Can't use function '\'' in math mode at position 31: …"', '>', '<', '\̲'̲', '(', ')', 'C…
if(isset(_GET['formhash']) &&
if(_SERVER['REQUEST_METHOD'] == 'GET' ) {
_SERVER['REQUEST_URI'];
} elseif(empty (ParseError: KaTeX parse error: Expected '}', got 'EOF' at end of input: …'formhash'])) {temp = ParseError: KaTeX parse error: Expected 'EOF', got '}' at position 66: …put'); }̲ else {temp = '';
}if(!empty(ParseError: KaTeX parse error: Expected '}', got 'EOF' at end of input: temp)) {temp = strtoupper(urldecode(urldecode(check as ParseError: KaTeX parse error: Expected '}', got 'EOF' at end of input: … if(strpos(temp, ParseError: KaTeX parse error: Expected 'EOF', got '}' at position 103: … } }̲ }
return true;
}
*/private function _xss_check() {temp = strtoupper(urldecode(urldecode(
if(strpos(temp, '<') !== false || strpos(temp, 'CONTENT-TRANSFER-ENCODING') !== false) {
system_error('request_tainting');
}
return true;
}
同时进行以下操作:
1. 在DiscuzX管理后台禁用登录/发布的验证码功能
2. 在火车头的发布模块中将登录模式改为数据包模式,填写用户名和密码然后测试发布,应该没问题了。