| @@ -151,13 +151,28 @@ | ||
| 151 | 151 | { |
| 152 | 152 | $base = str_replace(['http://www.', 'https://www.', 'http://', 'https://'], '', ACYM_LIVE); |
| 153 | 153 | $replacements = ['https://www.'.$base, 'http://www.'.$base, 'https://'.$base, 'http://'.$base]; |
| 154 | 154 | foreach ($replacements as $oneReplacement) { |
| 155 | - if (strpos($url, $oneReplacement) === false) { | |
| 155 | + $position = strpos($url, $oneReplacement); | |
| 156 | + if ($position === false) { | |
| 156 | 157 | continue; |
| 157 | 158 | } |
| 158 | 159 | |
| 159 | - return str_replace([$oneReplacement, '/'], [ACYM_ROOT, DS], urldecode($url)); | |
| 160 | + // Remove parameters | |
| 161 | + $relativeUrl = substr($url, $position + strlen($oneReplacement)); | |
| 162 | + $relativeUrl = preg_replace('/[?#].*$/', '', $relativeUrl); | |
| 163 | + | |
| 164 | + // Remove encoded / and . | |
| 165 | + $segments = []; | |
| 166 | + foreach (explode('/', $relativeUrl) as $oneSegment) { | |
| 167 | + $decodedSegment = urldecode($oneSegment); | |
| 168 | + if (preg_match('#[/\\\\?\#]#', $decodedSegment) === 1 || in_array($decodedSegment, ['.', '..'], true)) { | |
| 169 | + return $url; | |
| 170 | + } | |
| 171 | + $segments[] = $decodedSegment; | |
| 172 | + } | |
| 173 | + | |
| 174 | + return ACYM_ROOT.implode(DS, $segments); | |
| 160 | 175 | } |
| 161 | 176 | |
| 162 | 177 | return $url; |
| 163 | 178 | } |