POST, GET に多次元配列が使えない
2006.10.16 Mon/PM
MODxは「index.php」でMODxタグを除去しているんですが、スニペットなどで2階層以上の配列を受け取ろうとしても受け取れません。
以下を修正します。
[Core:index.php] 60
// Never allow request via get and post contain snippets, javascript or php
$modxtags = array('@<script[^>]*?>.*?</script>@si',
'@(\d+);@e',
'@\[\[(.*?)\]\]@si',
'@\[!(.*?)!\]@si',
'@\[\~(.*?)\~\]@si',
'@\[\((.*?)\)\]@si',
'@{{(.*?)}}@si',
'@\[\*(.*?)\*\]@si');
foreach($_POST as $key => $value) {
$_POST[$key] = preg_replace($modxtags,"", $value);
}
foreach($_GET as $key => $value) {
$_GET[$key] = preg_replace($modxtags,"", $value);
}
となっている部分を
// Never allow request via get and post contain snippets, javascript or php
$modxtags = array('@<script[^>]*?>.*?</script>@si',
'@(\d+);@e',
'@\[\[(.*?)\]\]@si',
'@\[!(.*?)!\]@si',
'@\[\~(.*?)\~\]@si',
'@\[\((.*?)\)\]@si',
'@{{(.*?)}}@si',
'@\[\*(.*?)\*\]@si');
/////edit
$_POST = array_map('modxtags', $_POST);
$_GET = array_map('modxtags', $_GET);
function modxtags($val)
{
global $modxtags;
if (is_array($val))
$val = array_map('modxtags', $val);
else
$val = preg_replace($modxtags, "", $val);
return $val;
}
のように書き換えることで下層配列にもフィルタを通すようにします。
ついでにここでNULLとか削除しておくといいかも…。
