Skip to content

Commit 1cf80d5

Browse files
committed
Prefer canonical rather than real path.
1 parent d74dad8 commit 1cf80d5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/FrontEnd.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Front-end handler (last modified: 2022.08.11).
11+
* This file: Front-end handler (last modified: 2022.08.19).
1212
*/
1313

1414
namespace phpMussel\FrontEnd;
@@ -259,7 +259,7 @@ public function view(string $Page = ''): void
259259
'magnification' => $this->Loader->Configuration['frontend']['magnification'],
260260

261261
/** Define active configuration file. */
262-
'ActiveConfigFile' => realpath($this->Loader->ConfigurationPath),
262+
'ActiveConfigFile' => $this->canonical($this->Loader->ConfigurationPath),
263263

264264
/** Current time and date. */
265265
'DateTime' => $this->Loader->timeFormat($this->Loader->Time, $this->Loader->Configuration['core']['time_format']),
@@ -2784,4 +2784,19 @@ private function arrayFromL10NDataToArray($References): array
27842784
}
27852785
return $Out;
27862786
}
2787+
2788+
/**
2789+
* Get canonical path (but not checking whether it's real).
2790+
*
2791+
* @param string $Path The path to check.
2792+
* @return string The canonicalised path.
2793+
*/
2794+
private function canonical(string $Path): string
2795+
{
2796+
$Path = str_replace("\\", '/', $Path);
2797+
while (preg_match('~/[^/]+/\.\./|/\./|/{2,}~', $Path)) {
2798+
$Path = preg_replace('~/[^/]+/\.\./|/\./|/{2,}~', '/', $Path);
2799+
}
2800+
return $Path;
2801+
}
27872802
}

0 commit comments

Comments
 (0)