This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new ea17c9d61b Improve handling of EL error messages.
ea17c9d61b is described below
commit ea17c9d61baf665d4bf5bd4b7f419b0c705c9abe
Author: Mark Thomas <[email protected]>
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 40f2ddeb4c..fc6b28a602 100644
--- a/java/org/apache/el/util/MessageFactory.java
+++ b/java/org/apache/el/util/MessageFactory.java
@@ -42,6 +42,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 9c2b9a41b9..7d0db6d06e 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: [email protected]
For additional commands, e-mail: [email protected]