You are here

protected static function RequestSanitizer::checkDestination in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Security/RequestSanitizer.php \Drupal\Core\Security\RequestSanitizer::checkDestination()
  2. 9 core/lib/Drupal/Core/Security/RequestSanitizer.php \Drupal\Core\Security\RequestSanitizer::checkDestination()

Checks a destination string to see if it is dangerous.

Parameters

string $destination: The destination string to check.

string[] $safe_keys: An array of keys to consider safe.

Return value

array The dangerous keys found in the destination parameter.

File

core/lib/Drupal/Core/Security/RequestSanitizer.php, line 130

Class

RequestSanitizer
Sanitizes user input.

Namespace

Drupal\Core\Security

Code

protected static function checkDestination($destination, array $safe_keys) {
  $dangerous_keys = [];
  $parts = UrlHelper::parse($destination);

  // If there is a query string, check its query parameters.
  if (!empty($parts['query'])) {
    static::stripDangerousValues($parts['query'], $safe_keys, $dangerous_keys);
  }
  return $dangerous_keys;
}