From 28e4885e5e8884b6a8f45708604e124139acf0a9 Mon Sep 17 00:00:00 2001 From: GodMeowIceSun Date: Fri, 31 May 2024 16:10:37 +0800 Subject: [PATCH] fix(#456): fix default charset problem Signed-off-by: GodMeowIceSun --- .../org/owasp/validator/html/util/ErrorMessageUtil.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/owasp/validator/html/util/ErrorMessageUtil.java b/src/main/java/org/owasp/validator/html/util/ErrorMessageUtil.java index baf4ebef..41127b18 100644 --- a/src/main/java/org/owasp/validator/html/util/ErrorMessageUtil.java +++ b/src/main/java/org/owasp/validator/html/util/ErrorMessageUtil.java @@ -23,6 +23,8 @@ */ package org.owasp.validator.html.util; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.text.MessageFormat; import java.util.ResourceBundle; @@ -87,6 +89,10 @@ public final class ErrorMessageUtil { private ErrorMessageUtil() {} public static String getMessage(ResourceBundle messages, String msgKey, Object[] arguments) { - return MessageFormat.format(messages.getString(msgKey), arguments); + return MessageFormat.format( + new String( + messages.getString(msgKey).getBytes(StandardCharsets.ISO_8859_1), + Charset.defaultCharset()), + arguments); } }