From c2819f1f5a2ffd5230029abe9054427f6523daab Mon Sep 17 00:00:00 2001 From: FoxInField <121326164+FoxInField@users.noreply.github.com> Date: Wed, 23 Apr 2025 17:23:10 +0800 Subject: [PATCH] Fix the problem of not being able to setup in OS without UTF-8 as default encoding (#7379) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind bug #### What this PR does / why we need it: This PR manually set UTF-8 charset while loading YAML file to fix the problem "java.nio.charset.MalformedInputException: Input length = 1". #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/6937 Fixes https://github.com/orgs/halo-dev/discussions/7375 #### Does this PR introduce a user-facing change? ```release-note 修复 Windows 下可能无法正常初始化的问题 ``` --- .../run/halo/app/security/preauth/SystemSetupEndpoint.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/src/main/java/run/halo/app/security/preauth/SystemSetupEndpoint.java b/application/src/main/java/run/halo/app/security/preauth/SystemSetupEndpoint.java index 62027aada..a9061bee8 100644 --- a/application/src/main/java/run/halo/app/security/preauth/SystemSetupEndpoint.java +++ b/application/src/main/java/run/halo/app/security/preauth/SystemSetupEndpoint.java @@ -289,7 +289,8 @@ public class SystemSetupEndpoint { var processedContent = PROPERTY_PLACEHOLDER_HELPER.replacePlaceholders(rawContent, properties); // load yaml to unstructured - var stringResource = new InMemoryResource(processedContent); + var stringResource = + new InMemoryResource(processedContent.getBytes(StandardCharsets.UTF_8)); var loader = new YamlUnstructuredLoader(stringResource); return loader.load(); })