This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git


The following commit(s) were added to refs/heads/master by this push:
     new b11591895 FormattableUtils.append re-parses literal output as format 
string (#1661)
b11591895 is described below

commit b11591895eed00e9f6e0bcb19178dedbaab4a971
Author: Gary Gregory <[email protected]>
AuthorDate: Mon May 18 20:09:50 2026 -0400

    FormattableUtils.append re-parses literal output as format string (#1661)
---
 .../java/org/apache/commons/lang3/text/FormattableUtils.java   |  3 +--
 .../org/apache/commons/lang3/text/FormattableUtilsTest.java    | 10 ++++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java 
b/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java
index d8d5d0d5d..a94232293 100644
--- a/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java
+++ b/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java
@@ -104,8 +104,7 @@ public static Formatter append(final CharSequence seq, 
final Formatter formatter
         for (int i = buf.length(); i < width; i++) {
             buf.insert(leftJustify ? i : 0, padChar);
         }
-        formatter.format(buf.toString());
-        return formatter;
+        return formatter.format(SIMPLEST_FORMAT, buf.toString());
     }
 
     /**
diff --git 
a/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java 
b/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java
index 20aff0d11..9bc896c34 100644
--- a/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java
@@ -115,4 +115,14 @@ void testIllegalEllipsis() {
         assertIllegalArgumentException(() -> FormattableUtils.append("foo", 
new Formatter(), 0, -1, 1, "xx"));
     }
 
+    @Test
+    void testPercentLiteral() {
+        assertEquals("100% done", FormattableUtils.append("100% done", new 
Formatter(), 0, -1, -1).toString());
+    }
+
+    @Test
+    void testPercentLiteralX2() {
+        assertEquals("50% off 100% items", FormattableUtils.append("50% off 
100% items", new Formatter(), 0, -1, -1).toString());
+    }
+
 }

Reply via email to