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

Sanitizes unsafe keys from request input.

Parameters

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

string[] $allowlist: Allowed list 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 3386
Functions that need to be loaded on every Backdrop request.

Code

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

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

  return $sanitized_keys;
}