From e9b414fbe39eea609c5cfdfb0266527977495802 Mon Sep 17 00:00:00 2001 From: Naoto Kobayashi Date: Tue, 16 Nov 2021 00:40:52 +0900 Subject: OC_Util: Add fallbacks to check if current locale is UTF8 Using escapeshellcmd to get current locale causes error if the function is disabled. Add fallbacks to prevent the error. Signed-off-by: Naoto Kobayashi --- tests/lib/UtilTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/lib/UtilTest.php b/tests/lib/UtilTest.php index 65147ed52c9..bb328c5998d 100644 --- a/tests/lib/UtilTest.php +++ b/tests/lib/UtilTest.php @@ -74,13 +74,15 @@ class UtilTest extends \Test\TestCase { $this->assertEquals("/%C2%A7%23%40test%25%26%5E%C3%A4/-child", $result); } - public function testIsSetLocaleWorking() { - // OC_Util::isSetLocaleWorking() assumes escapeshellcmd('§') returns '' with non-UTF-8 locale. + public function testIsNonUTF8Locale() { + // OC_Util::isNonUTF8Locale() assumes escapeshellcmd('§') returns '' with non-UTF-8 locale. $locale = setlocale(LC_CTYPE, 0); setlocale(LC_CTYPE, 'C'); $this->assertEquals('', escapeshellcmd('§')); + $this->assertEquals('\'\'', escapeshellarg('§')); setlocale(LC_CTYPE, 'C.UTF-8'); $this->assertEquals('§', escapeshellcmd('§')); + $this->assertEquals('\'§\'', escapeshellarg('§')); setlocale(LC_CTYPE, $locale); } -- cgit v1.2.3