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

markt-asf pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 612837e3a788fd77c7fd6629b079a46d5837fb08
Author: remm <[email protected]>
AuthorDate: Wed May 27 11:02:54 2026 +0200

    Fix unused end <-> length confusion
---
 java/org/apache/tomcat/util/json/JSONFilter.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/tomcat/util/json/JSONFilter.java 
b/java/org/apache/tomcat/util/json/JSONFilter.java
index 3d4aff5f11..11710f1bee 100644
--- a/java/org/apache/tomcat/util/json/JSONFilter.java
+++ b/java/org/apache/tomcat/util/json/JSONFilter.java
@@ -85,7 +85,7 @@ public class JSONFilter {
          */
         StringBuilder escaped = null;
         int lastUnescapedStart = off;
-        for (int i = off; i < length; i++) {
+        for (int i = off; i < off + length; i++) {
             char c = input.charAt(i);
             if (c < 0x20 || c == 0x22 || c == 0x5c || 
Character.isHighSurrogate(c) || Character.isLowSurrogate(c)) {
                 if (escaped == null) {
@@ -108,11 +108,11 @@ public class JSONFilter {
             if (off == 0 && length == input.length()) {
                 return input;
             } else {
-                return input.subSequence(off, length - off);
+                return input.subSequence(off, off + length);
             }
         } else {
-            if (lastUnescapedStart < length) {
-                escaped.append(input.subSequence(lastUnescapedStart, length));
+            if (lastUnescapedStart < off + length) {
+                escaped.append(input.subSequence(lastUnescapedStart, off + 
length));
             }
             return escaped.toString();
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to