summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNaoto Kobayashi <naoto.kobayashi4c@gmail.com>2021-11-16 00:40:52 +0900
committerNaoto Kobayashi <naoto.kobayashi4c@gmail.com>2021-11-16 00:40:52 +0900
commite9b414fbe39eea609c5cfdfb0266527977495802 (patch)
tree938dfd044cfea68f349613f8a7debc460699fce3 /tests
parent25f15f86a98c737f4847f6e861d809ffe104eedd (diff)
downloadnextcloud-server-e9b414fbe39eea609c5cfdfb0266527977495802.tar.gz
nextcloud-server-e9b414fbe39eea609c5cfdfb0266527977495802.zip
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 <naoto.kobayashi4c@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/UtilTest.php6
1 files changed, 4 insertions, 2 deletions
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);
}