1 bootstrap.inc _backdrop_bootstrap_sanitize_input(&$input, $whitelist = array())

Sanitizes unsafe keys from request input.

Parameters

mixed $input: The input data array from a request to be sanitized.

string[] $whitelist: Whitelist of input keys that are considered acceptable.

Return value

string[]: The list of any input keys have been filtered out, if any.

File

core/includes/bootstrap.inc, line 3290
Functions that need to be loaded on every Backdrop request.

Code

function _backdrop_bootstrap_sanitize_input(&$input, $whitelist = array()) {
  $sanitized_keys = array();

  if (is_array($input)) {
    foreach ($input as $key => $value) {
      if ($key !== '' && substr($key, 0, 1) === '#' && !in_array($key, $whitelist, TRUE)) {
        unset($input[$key]);
        $sanitized_keys[] = $key;
      }
      elseif (is_array($input[$key])) {
        $sanitized_keys = array_merge($sanitized_keys, _backdrop_bootstrap_sanitize_input($input[$key], $whitelist));
      }
    }
  }

  return $sanitized_keys;
}