mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-04 17:44:38 +09:00
Move some security measures from ModuleHandler to Context
This commit is contained in:
parent
b5740052fc
commit
85c2f87f13
2 changed files with 9 additions and 21 deletions
|
|
@ -1439,7 +1439,15 @@ class Context
|
||||||
{
|
{
|
||||||
$_val = (int)$_val;
|
$_val = (int)$_val;
|
||||||
}
|
}
|
||||||
elseif(in_array($key, array('mid', 'vid', 'search_target', 'search_keyword', 'xe_validator_id')) || $_SERVER['REQUEST_METHOD'] === 'GET')
|
elseif(in_array($key, array('mid', 'vid', 'act', 'module')))
|
||||||
|
{
|
||||||
|
$_val = preg_match('/^[a-zA-Z0-9_-]+$/', $_val) ? $_val : null;
|
||||||
|
if($_val === null)
|
||||||
|
{
|
||||||
|
self::$_instance->security_check = 'DENY ALL';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif(in_array($key, array('search_target', 'search_keyword', 'xe_validator_id')) || $_SERVER['REQUEST_METHOD'] === 'GET')
|
||||||
{
|
{
|
||||||
$_val = escape($_val, false);
|
$_val = escape($_val, false);
|
||||||
if(ends_with('url', $key, false))
|
if(ends_with('url', $key, false))
|
||||||
|
|
|
||||||
|
|
@ -94,26 +94,6 @@ class ModuleHandler extends Handler
|
||||||
Context::set('mid', $this->mid = null);
|
Context::set('mid', $this->mid = null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate variables to prevent XSS
|
|
||||||
$isInvalid = false;
|
|
||||||
if($this->module && !preg_match('/^[a-zA-Z0-9_-]+$/', $this->module))
|
|
||||||
{
|
|
||||||
$isInvalid = true;
|
|
||||||
}
|
|
||||||
if($this->mid && !preg_match('/^[a-zA-Z0-9_-]+$/', $this->mid))
|
|
||||||
{
|
|
||||||
$isInvalid = true;
|
|
||||||
}
|
|
||||||
if($this->act && !preg_match('/^[a-zA-Z0-9_-]+$/', $this->act))
|
|
||||||
{
|
|
||||||
$isInvalid = true;
|
|
||||||
}
|
|
||||||
if($isInvalid)
|
|
||||||
{
|
|
||||||
$this->error = 'msg_security_violation';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// call a trigger before moduleHandler init
|
// call a trigger before moduleHandler init
|
||||||
self::triggerCall('moduleHandler.init', 'before', $this);
|
self::triggerCall('moduleHandler.init', 'before', $this);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue