NEW Add extension point to Director::is_site_url

This commit is contained in:
Michal Kleiner 2021-05-11 00:07:12 +12:00
parent e0548b208e
commit f8a9431152
1 changed files with 10 additions and 0 deletions

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);
}