MDL-49401 moodlelib: PARAM_LOCALURL supports loginhttps

This commit is contained in:
Frederic Massart
2015-05-05 18:31:13 +08:00
committed by Mr. Jenkins (CiBoT)
parent b3f5865eab
commit d031c2dcb9
2 changed files with 31 additions and 5 deletions
+7 -1
View File
@@ -1032,10 +1032,16 @@ function clean_param($param, $type) {
// Allow http absolute, root relative and relative URLs within wwwroot.
$param = clean_param($param, PARAM_URL);
if (!empty($param)) {
// Simulate the HTTPS version of the site.
$httpswwwroot = str_replace('http://', 'https://', $CFG->wwwroot);
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)) {
// Absolute, and matches our httpswwwroot.
} else {
// Relative - let's make sure there are no tricks.
if (validateUrlSyntax('/' . $param, 's-u-P-a-p-f+q?r?')) {