Skip to content

Commit 4c25407

Browse files
committed
Add a configuration check for encoding detection
1 parent 38af044 commit 4c25407

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

webapp/src/Service/CheckConfigService.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,14 @@ public function checkPhpSettings(): ConfigCheckItem
189189
(isset($sizes[$var]) ? Utils::printsize($sizes[$var]) : "unlimited"));
190190
}
191191

192+
$desc .= "\nFor submission encoding detection, the detect order should atcontain all expected submission encodings:\n";
193+
$desc .= sprintf(" - `mbstring.detect_order` should at least contain `UTF-8` (now set to `%s`)\n", implode(', ', mb_detect_order()));
194+
if (!in_array('UTF-8', mb_detect_order())) {
195+
if ($result !== 'E') {
196+
$result = 'W';
197+
}
198+
}
199+
192200
$this->stopwatch->stop(__FUNCTION__);
193201
return new ConfigCheckItem(
194202
caption: 'PHP settings',

webapp/src/Utils/Utils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ public static function reencodeUtf8(string $source): string {
10691069
return $encoded;
10701070
}
10711071
}
1072-
return "Could not display file as UTF-8, is it binary?";
1072+
return "Could not display file as UTF-8.\nCheck your PHP settings if you did not expect this file to be binary.";
10731073
}
10741074

10751075
/**

0 commit comments

Comments
 (0)