This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.0.x by this push: new 650391f475 Improve handling of EL error messages. 650391f475 is described below commit 650391f475cee7e15f94ddcbb7a9234965e95941 Author: Mark Thomas <ma...@apache.org> AuthorDate: Mon Aug 29 07:39:15 2022 +0100 Improve handling of EL error messages. Ensure instances of Number are not formatted in unexpected ways. --- java/org/apache/el/util/MessageFactory.java | 10 ++++++++++ webapps/docs/changelog.xml | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/java/org/apache/el/util/MessageFactory.java b/java/org/apache/el/util/MessageFactory.java index 9222204b46..20e530d4ef 100644 --- a/java/org/apache/el/util/MessageFactory.java +++ b/java/org/apache/el/util/MessageFactory.java @@ -43,6 +43,16 @@ public final class MessageFactory { public static String get(final String key, final Object... args) { String value = get(key); + // Convert all Number arguments to String else MessageFormat may try to + // format them in unexpected ways. + if (args != null) { + for (int i = 0; i < args.length; i++) { + if (args[i] instanceof Number) { + args[i] = args[i].toString(); + } + } + } + MessageFormat mf = new MessageFormat(value); return mf.format(args, new StringBuffer(), null).toString(); } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index f525c1a945..4c77efa327 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -226,6 +226,10 @@ that is now detrimental rather than helpful. Pull request <pr>547</pr> provided by rmannibucau. (markt) </fix> + <fix> + Improve handling of EL error messages so instances of Number are not + formatted in unexpected ways. (markt) + </fix> </changelog> </subsection> <subsection name="Cluster"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org