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

remm 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 2e0f278  Improve escaping for code in call method
2e0f278 is described below

commit 2e0f2783bbc511f2dc847659516d22872102fc5f
Author: remm <r...@apache.org>
AuthorDate: Sat Jan 1 20:56:08 2022 +0100

    Improve escaping for code in call method
---
 java/org/apache/tomcat/util/digester/CallMethodRule.java | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/tomcat/util/digester/CallMethodRule.java 
b/java/org/apache/tomcat/util/digester/CallMethodRule.java
index 28176ab..bd65535 100644
--- a/java/org/apache/tomcat/util/digester/CallMethodRule.java
+++ b/java/org/apache/tomcat/util/digester/CallMethodRule.java
@@ -393,13 +393,9 @@ public class CallMethodRule extends Rule {
                     code.append(", ");
                 }
                 if (bodyText != null) {
-                    StringBuilder bodyTextParam = new StringBuilder();
-                    for (String bodyPart : bodyText.split("\n")) {
-                        bodyTextParam.append(bodyPart.trim()).append(' ');
-                    }
-                    
code.append("\"").append(bodyTextParam.toString().trim().replace("\"", 
"\\\"")).append("\"");
+                    
code.append("\"").append(IntrospectionUtils.escape(bodyText)).append("\"");
                 } else if (paramValues[i] instanceof String) {
-                    
code.append("\"").append(paramValues[i].toString()).append("\"");
+                    
code.append("\"").append(IntrospectionUtils.escape(paramValues[i].toString())).append("\"");
                 } else {
                     code.append(digester.toVariableName(paramValues[i]));
                 }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to