Skip to content

Commit

Permalink
MDL-63770 core: 'port' should be an integer like in parse_url()
Browse files Browse the repository at this point in the history
Plus trivial comment cleanup.
  • Loading branch information
scara authored and junpataleta committed Jul 15, 2021
1 parent 1983718 commit 7910fa3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/setuplib.php
Expand Up @@ -897,8 +897,9 @@ function initialise_fullme() {
$_SERVER['SERVER_PORT'] = 443; // Assume default ssl port for the proxy.
}

// hopefully this will stop all those "clever" admins trying to set up moodle
// with two different addresses in intranet and Internet
// Hopefully this will stop all those "clever" admins trying to set up moodle
// with two different addresses in intranet and Internet.
// Port forwarding is still allowed!
if (!empty($CFG->reverseproxy) && $rurl['host'] === $wwwroot['host'] && (empty($wwwroot['port']) || $rurl['port'] === $wwwroot['port'])) {
print_error('reverseproxyabused', 'error');
}
Expand Down Expand Up @@ -950,7 +951,7 @@ function setup_get_remote_url() {
} else {
$rurl['host'] = null;
}
$rurl['port'] = $_SERVER['SERVER_PORT'];
$rurl['port'] = (int)$_SERVER['SERVER_PORT'];
$rurl['path'] = $_SERVER['SCRIPT_NAME']; // Script path without slash arguments
$rurl['scheme'] = (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] === 'off' or $_SERVER['HTTPS'] === 'Off' or $_SERVER['HTTPS'] === 'OFF') ? 'http' : 'https';

Expand Down

0 comments on commit 7910fa3

Please sign in to comment.