Skip to content

Commit b1430a2

Browse files
feat: enhance Java encoding check with detailed diagnostics
Improve the non-UTF-8 encoding detection in ConfigureCheckService to provide comprehensive diagnostic information when Java reports incorrect encoding. The enhanced check now: - Shows the specific encoding detected by Java - Displays current PHP environment variables (LC_CTYPE, LC_ALL, LANG) - Provides step-by-step resolution instructions - Links to issue #4872 with detailed troubleshooting This helps administrators quickly identify and resolve locale inheritance issues between PHP and Java that cause character encoding problems in PDF signatures. Ref: #4872 Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent c11c1db commit b1430a2

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

lib/Service/Install/ConfigureCheckService.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,35 @@ private function checkJava(): array {
437437
];
438438
}
439439
if (!str_contains($matches['encoding'], 'UTF-8')) {
440+
$detectedEncoding = trim($matches['encoding']);
441+
$phpLocale = setlocale(LC_CTYPE, 0);
442+
$phpLcAll = getenv('LC_ALL');
443+
$phpLang = getenv('LANG');
444+
445+
$tip = sprintf(
446+
"Java detected encoding \"%s\" but UTF-8 is required.\n\n"
447+
. "**Current PHP environment:**\n"
448+
. "- LC_CTYPE: %s\n"
449+
. "- LC_ALL: %s\n"
450+
. "- LANG: %s\n\n"
451+
. "**To fix this issue:**\n"
452+
. "1. Set LC_ALL and LANG environment variables (e.g., LC_ALL=en_US.UTF-8) for your web server user\n"
453+
. "2. Restart your web server after making changes\n"
454+
. "3. Verify with command: `locale charmap` (should return UTF-8)\n\n"
455+
. 'For more details, see: [Issue #4872](https://github.com/LibreSign/libresign/issues/4872)',
456+
$detectedEncoding,
457+
$phpLocale ?: 'not set',
458+
$phpLcAll ?: 'not set',
459+
$phpLang ?: 'not set'
460+
);
440461
return $this->result['java'] = [
441462
(new ConfigureCheckHelper())
442-
->setInfoMessage('Non-UTF-8 encoding detected. This may cause issues with accented or special characters')
463+
->setInfoMessage(sprintf(
464+
'Non-UTF-8 encoding detected: %s. This may cause issues with accented or special characters',
465+
$detectedEncoding
466+
))
443467
->setResource('java')
444-
->setTip(' Ensure the system encoding is UTF-8. You can check it using: locale charmap'),
468+
->setTip($tip),
445469
];
446470
}
447471
return $this->result['java'] = [

0 commit comments

Comments
 (0)