mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-16 21:41:31 +02:00
Move regexps to a separate method #179.
This commit is contained in:
@@ -138,6 +138,17 @@ class maintenance_static_page_generator {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all URLs from file content using regular expressions.
|
||||
*
|
||||
* @param string $contents Content of the file
|
||||
* @return array Array of all matches in multi-dimensional array
|
||||
*/
|
||||
public function get_urls_from_stylesheet($contents) {
|
||||
preg_match_all('#url\([\'"]?(?!data:)([^\'"\)]+)#', $contents, $matches);
|
||||
return $matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for urls inside filename.
|
||||
*
|
||||
@@ -148,9 +159,8 @@ class maintenance_static_page_generator {
|
||||
global $CFG;
|
||||
|
||||
$contents = file_get_contents($filename);
|
||||
if (!preg_match_all('#url\([\'"]?(?!data:)([^\'"\)]+)#', $contents, $matches)) {
|
||||
return;
|
||||
}
|
||||
$matches = $this->get_urls_from_stylesheet($contents);
|
||||
|
||||
foreach ($matches[1] as $originalurl) {
|
||||
// Allow incomplete URLs in CSS, assume it is from moodle root.
|
||||
if (maintenance_static_page_io::is_url($originalurl)) {
|
||||
|
||||
Reference in New Issue
Block a user