mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-50688 lib: fix local url validation bug
Change-Id: I350bb8c9ace5cc0403f083f728c100097be7aa7e Reviewed-on: https://review.totaralms.com/8101 Tested-by: Jenkins Automation <jenkins@totaralms.com> Reviewed-by: Sam Hemelryk <sam.hemelryk@totaralms.com> Reviewed-by: Alastair Munro <alastair.munro@totaralms.com>
This commit is contained in:
parent
489878ad09
commit
5c1f41f058
@ -1033,11 +1033,15 @@ function clean_param($param, $type) {
|
||||
// Simulate the HTTPS version of the site.
|
||||
$httpswwwroot = str_replace('http://', 'https://', $CFG->wwwroot);
|
||||
|
||||
if (preg_match(':^/:', $param)) {
|
||||
if ($param === $CFG->wwwroot) {
|
||||
// Exact match;
|
||||
} else if (!empty($CFG->loginhttps) && $param === $httpswwwroot) {
|
||||
// Exact match;
|
||||
} else if (preg_match(':^/:', $param)) {
|
||||
// Root-relative, ok!
|
||||
} else if (preg_match('/^' . preg_quote($CFG->wwwroot, '/') . '/i', $param)) {
|
||||
} else if (preg_match('/^' . preg_quote($CFG->wwwroot . '/', '/') . '/i', $param)) {
|
||||
// Absolute, and matches our wwwroot.
|
||||
} else if (!empty($CFG->loginhttps) && preg_match('/^' . preg_quote($httpswwwroot, '/') . '/i', $param)) {
|
||||
} else if (!empty($CFG->loginhttps) && preg_match('/^' . preg_quote($httpswwwroot . '/', '/') . '/i', $param)) {
|
||||
// Absolute, and matches our httpswwwroot.
|
||||
} else {
|
||||
// Relative - let's make sure there are no tricks.
|
||||
|
Loading…
x
Reference in New Issue
Block a user