I should also mention $modx->sanitizeRequest(), which pretty much clears everything suspicious (including MODX tags if the allow_tags_in_post System Setting is set to false). It's called on every request to sanitize the $_POST data.
public function sanitizeRequest() {
$modxtags = array_values($this->modx->sanitizePatterns);
modX :: sanitize($_GET, $modxtags, 0);
if ($this->modx->getOption('allow_tags_in_post',null,true)) {
modX :: sanitize($_POST);
} else {
modX :: sanitize($_POST, $modxtags);
}
modX :: sanitize($_COOKIE, $modxtags);
modX :: sanitize($_REQUEST, $modxtags);
$rAlias = $this->modx->getOption('request_param_alias', null, 'q');
if (isset ($_GET[$rAlias])) {
$_GET[$rAlias] = preg_replace("/[^A-Za-z0-9_\-\.\/]/", "", $_GET[$rAlias]);
}
}
public static function sanitize(array &$target, array $patterns= array(), $depth= 3, $nesting= 10) {
while (list($key, $value)= each($target)) {
if (is_array($value) && $depth > 0) {
modX :: sanitize($value, $patterns, $depth-1);
} elseif (is_string($value)) {
if (!empty($patterns)) {
foreach ($patterns as $pattern) {
$nesting = ((integer) $nesting ? (integer) $nesting : 10);
$iteration = 1;
while ($iteration <= $nesting && preg_match($pattern, $value)) {
$value= preg_replace($pattern, '', $value);
$iteration++;
}
}
}
if (get_magic_quotes_gpc()) {
$target[$key]= stripslashes($value);
} else {
$target[$key]= $value;
}
}
}
return $target;
}