Skip to content

Commit 526dfbc

Browse files
authored
Merge pull request #6062 from LibreSign/backport/6060/stable32
[stable32] feat: improve java encoding check
2 parents c11c1db + c2669e6 commit 526dfbc

2 files changed

Lines changed: 36 additions & 3 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'] = [

src/views/Settings/ConfigureCheck.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
</td>
2121
<td v-html="row.message" />
2222
<td>{{ row.resource }}</td>
23-
<td>{{ row.tip }}</td>
23+
<td class="tip-cell">
24+
<NcRichText :text="row.tip" :autolink="true" :use-markdown="true" />
25+
</td>
2426
</tr>
2527
</tbody>
2628
</table>
@@ -29,13 +31,15 @@
2931
<script>
3032
import { translate as t } from '@nextcloud/l10n'
3133
34+
import NcRichText from '@nextcloud/vue/dist/Components/NcRichText.js'
3235
import NcSettingsSection from '@nextcloud/vue/components/NcSettingsSection'
3336
3437
import { useConfigureCheckStore } from '../../store/configureCheck.js'
3538
3639
export default {
3740
name: 'ConfigureCheck',
3841
components: {
42+
NcRichText,
3943
NcSettingsSection,
4044
},
4145
setup() {
@@ -61,4 +65,9 @@ table {
6165
.info {
6266
color: orange;
6367
}
68+
.tip-cell {
69+
white-space: normal;
70+
word-wrap: break-word;
71+
max-width: 500px;
72+
}
6473
</style>

0 commit comments

Comments
 (0)