|
8 | 8 | * License: GNU/GPLv2 |
9 | 9 | * @see LICENSE.txt |
10 | 10 | * |
11 | | - * This file: Front-end handler (last modified: 2022.08.11). |
| 11 | + * This file: Front-end handler (last modified: 2022.08.19). |
12 | 12 | */ |
13 | 13 |
|
14 | 14 | namespace phpMussel\FrontEnd; |
@@ -259,7 +259,7 @@ public function view(string $Page = ''): void |
259 | 259 | 'magnification' => $this->Loader->Configuration['frontend']['magnification'], |
260 | 260 |
|
261 | 261 | /** Define active configuration file. */ |
262 | | - 'ActiveConfigFile' => realpath($this->Loader->ConfigurationPath), |
| 262 | + 'ActiveConfigFile' => $this->canonical($this->Loader->ConfigurationPath), |
263 | 263 |
|
264 | 264 | /** Current time and date. */ |
265 | 265 | 'DateTime' => $this->Loader->timeFormat($this->Loader->Time, $this->Loader->Configuration['core']['time_format']), |
@@ -2784,4 +2784,19 @@ private function arrayFromL10NDataToArray($References): array |
2784 | 2784 | } |
2785 | 2785 | return $Out; |
2786 | 2786 | } |
| 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 | + } |
2787 | 2802 | } |
0 commit comments