mirror of
https://github.com/moodle/moodle.git
synced 2025-02-22 10:57:20 +01:00
MDL-83293 core: Fix path separator when guessing the base path
Ensure that path separator for the script when guessing the base path uses forward slash instead of the OS' directory separator. (e.g. "\" in Windows)
This commit is contained in:
parent
0eacab846e
commit
f173a7026a
@ -92,14 +92,17 @@ class router {
|
||||
// Moodle is not guaranteed to exist at the domain root.
|
||||
// Strip out the current script.
|
||||
$scriptroot = parse_url($CFG->wwwroot, PHP_URL_PATH);
|
||||
$scriptfile = str_replace(
|
||||
realpath($CFG->dirroot),
|
||||
'',
|
||||
realpath($_SERVER['SCRIPT_FILENAME']),
|
||||
);
|
||||
// Replace occurrences of backslashes with forward slashes, especially on Windows.
|
||||
$scriptfile = str_replace('\\', '/', $scriptfile);
|
||||
$relativeroot = sprintf(
|
||||
'%s%s',
|
||||
$scriptroot,
|
||||
str_replace(
|
||||
realpath($CFG->dirroot),
|
||||
'',
|
||||
realpath($_SERVER['SCRIPT_FILENAME']),
|
||||
),
|
||||
$scriptfile,
|
||||
);
|
||||
|
||||
// The server is not configured to rewrite unknown requests to automatically use the router.
|
||||
|
Loading…
x
Reference in New Issue
Block a user