X Tutup
Skip to content

Commit 89c6b03

Browse files
authored
Merge pull request #40158 from owncloud/utf8_encode-mb_convert_encoding
[full-ci] Convert from utf8_encode to mb_convert_encoding
2 parents 2b78220 + 17f56e0 commit 89c6b03

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

changelog/unreleased/40158

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Bugfix: Convert from utf8_encode to mb_convert_encoding
2+
3+
Function `utf8_encode` will be deprecated and removed in future PHP versions.
4+
It has been replaced with function mb_convert_encoding.
5+
6+
https://github.com/owncloud/core/pull/40158

lib/private/AppFramework/Http/Request.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,15 +689,13 @@ public function getPathInfo() {
689689
}
690690

691691
$pathInfo = $this->getRawPathInfo();
692-
// following is taken from \Sabre\HTTP\URLUtil::decodePathSegment
693692
$pathInfo = \rawurldecode($pathInfo);
694693
$encoding = \mb_detect_encoding($pathInfo, ['UTF-8', 'ISO-8859-1']);
695694

696695
switch ($encoding) {
697696
case 'ISO-8859-1':
698-
$pathInfo = \utf8_encode($pathInfo);
697+
$pathInfo = \mb_convert_encoding($pathInfo, 'UTF-8', $encoding);
699698
}
700-
// end copy
701699

702700
return $pathInfo;
703701
}

tests/lib/AppFramework/Http/RequestTest.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,9 +1280,15 @@ public function testGetPathInfoWithoutSetEnvGeneric($requestUri, $scriptName, $e
12801280
* @dataProvider genericPathInfoProvider
12811281
* @param string $requestUri
12821282
* @param string $scriptName
1283-
* @param string $expected
1283+
* @param string $expectedGetPathInfo
1284+
* @param string $expectedGetRawPathInfo
12841285
*/
1285-
public function testGetRawPathInfoWithoutSetEnvGeneric($requestUri, $scriptName, $expected) {
1286+
public function testGetRawPathInfoWithoutSetEnvGeneric($requestUri, $scriptName, $expectedGetPathInfo, $expectedGetRawPathInfo) {
1287+
if ($expectedGetRawPathInfo === '') {
1288+
$expected = $expectedGetPathInfo;
1289+
} else {
1290+
$expected = $expectedGetRawPathInfo;
1291+
}
12861292
$request = new Request(
12871293
[
12881294
'server' => [
@@ -1350,14 +1356,15 @@ public function testGetPathInfoWithoutSetEnv($requestUri, $scriptName, $expected
13501356
*/
13511357
public function genericPathInfoProvider() {
13521358
return [
1353-
['/core/index.php?XDEBUG_SESSION_START=14600', '/core/index.php', ''],
1354-
['/index.php/apps/files/', 'index.php', '/apps/files/'],
1355-
['/index.php/apps/files/../&/&?someQueryParameter=QueryParam', 'index.php', '/apps/files/../&/&'],
1356-
['/remote.php/漢字編碼方法 / 汉字编码方法', 'remote.php', '/漢字編碼方法 / 汉字编码方法'],
1357-
['///removeTrailin//gSlashes///', 'remote.php', '/removeTrailin/gSlashes/'],
1358-
['/remove/multiple/Slashes/In/ScriptName/', '//remote.php', '/remove/multiple/Slashes/In/ScriptName/'],
1359-
['/', '/', ''],
1360-
['', '', ''],
1359+
['/core/index.php?XDEBUG_SESSION_START=14600', '/core/index.php', '', ''],
1360+
['/index.php/apps/files/', 'index.php', '/apps/files/', ''],
1361+
['/index.php/apps/files/../&/&?someQueryParameter=QueryParam', 'index.php', '/apps/files/../&/&', ''],
1362+
['/remote.php/漢字編碼方法 / 汉字编码方法', 'remote.php', '/漢字編碼方法 / 汉字编码方法', ''],
1363+
['/remote.php/pound-cent-AE-%A3%A2%C6-in-ISO-8859-1', 'remote.php', '/pound-cent-AE-£¢Æ-in-ISO-8859-1', '/pound-cent-AE-%A3%A2%C6-in-ISO-8859-1'],
1364+
['///removeTrailin//gSlashes///', 'remote.php', '/removeTrailin/gSlashes/', ''],
1365+
['/remove/multiple/Slashes/In/ScriptName/', '//remote.php', '/remove/multiple/Slashes/In/ScriptName/', ''],
1366+
['/', '/', '', ''],
1367+
['', '', '', ''],
13611368
];
13621369
}
13631370

0 commit comments

Comments
 (0)
X Tutup