Merge pull request #10027 from chrometoasters/pulls/director-extension-point-4.8

NEW Add extension point to Director::is_site_url
This commit is contained in:
Steve Boyd 2021-08-07 09:56:31 +12:00 committed by GitHub
commit 0ea36ad5d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -854,6 +854,9 @@ class Director implements TemplateGlobalProvider
* Useful to check before redirecting based on a URL from user submissions through $_GET or $_POST,
* and avoid phishing attacks by redirecting to an attackers server.
*
* Provides an extension point to allow extra checks on the URL to allow some external URLs,
* e.g. links on secondary domains that point to the same CMS, or subsite domains.
*
* @param string $url
*
* @return bool
@ -871,6 +874,13 @@ class Director implements TemplateGlobalProvider
return true;
}
// Allow extensions to weigh in
$isSiteUrl = false;
static::singleton()->extend('updateIsSiteUrl', $isSiteUrl, $url);
if ($isSiteUrl) {
return true;
}
// Relative urls always are site urls
return self::is_relative_url($url);
}