Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UriSigner.php

function UriSigner::check

Checks that a URI contains the correct hash. Also checks if the URI has not expired (If you used expiration during signing).

1 call to UriSigner::check()
UriSigner::checkRequest in vendor/symfony/http-foundation/UriSigner.php

File

vendor/symfony/http-foundation/UriSigner.php, line 90

Class

UriSigner
@author Fabien Potencier <fabien@symfony.com>

Namespace

Symfony\Component\HttpFoundation

Code

public function check(string $uri) : bool {
    $url = parse_url($uri);
    $params = [];
    if (isset($url['query'])) {
        parse_str($url['query'], $params);
    }
    if (empty($params[$this->hashParameter])) {
        return false;
    }
    $hash = $params[$this->hashParameter];
    unset($params[$this->hashParameter]);
    if (!hash_equals($this->computeHash($this->buildUrl($url, $params)), $hash)) {
        return false;
    }
    if ($expiration = $params[$this->expirationParameter] ?? false) {
        return time() < $expiration;
    }
    return true;
}
RSS feed
Powered by Drupal