Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=28852
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 28 Feb 2011 18:15:48 +0000 (18:15 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 28 Feb 2011 18:15:48 +0000 (18:15 +0000)
Add URL encoding where missing to parameters in URLs presented by Ant tasks to the Manager application.
Based on a patch by Stephane Bailliez.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1075458 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/ant/JMXGetTask.java
java/org/apache/catalina/ant/JMXQueryTask.java
java/org/apache/catalina/ant/JMXSetTask.java
java/org/apache/catalina/ant/ResourcesTask.java
java/org/apache/catalina/ant/UndeployTask.java
webapps/docs/changelog.xml

index 2f205e3..c5899da 100644 (file)
@@ -19,6 +19,9 @@
 package org.apache.catalina.ant;
 
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
 import org.apache.tools.ant.BuildException;
 
 
@@ -90,8 +93,13 @@ public class JMXGetTask extends AbstractCatalinaTask {
                 ("Must specify 'bean' and 'attribute' attributes");
         }
         log("Getting attribute " + attribute +
-                " in bean " + bean ); 
-        execute("/jmxproxy/?get=" + bean 
-                + "&att=" + attribute );
+                " in bean " + bean );
+        try {
+            execute("/jmxproxy/?get=" + URLEncoder.encode(bean, getCharset()) 
+                    + "&att=" + URLEncoder.encode(attribute, getCharset()));
+        } catch (UnsupportedEncodingException e) {
+            throw new BuildException
+                ("Invalid 'charset' attribute: " + getCharset());
+        }
     }
 }
index 8cd960a..e5f030d 100644 (file)
@@ -19,6 +19,9 @@
 package org.apache.catalina.ant;
 
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
 import org.apache.tools.ant.BuildException;
 
 
@@ -73,7 +76,17 @@ public class JMXQueryTask extends AbstractCatalinaTask {
     @Override
     public void execute() throws BuildException {
         super.execute();
-        String queryString = (query == null) ? "":("?qry="+query);
+        String queryString;
+        if (query == null) {
+            queryString = "";
+        } else {
+            try {
+                queryString = "?qry=" + URLEncoder.encode(query, getCharset());
+            } catch (UnsupportedEncodingException e) {
+                throw new BuildException
+                    ("Invalid 'charset' attribute: " + getCharset());
+            }
+        }
         log("Query string is " + queryString); 
         execute ("/jmxproxy/" + queryString);
     }
index 12c562e..292ce09 100644 (file)
@@ -19,6 +19,9 @@
 package org.apache.catalina.ant;
 
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
 import org.apache.tools.ant.BuildException;
 
 
@@ -113,8 +116,13 @@ public class JMXSetTask extends AbstractCatalinaTask {
         log("Setting attribute " + attribute +
                             " in bean " + bean +
                             " to " + value); 
-        execute("/jmxproxy/?set=" + bean 
-                + "&att=" + attribute 
-                + "&val=" + value);
+        try {
+            execute("/jmxproxy/?set=" + URLEncoder.encode(bean, getCharset()) 
+                    + "&att=" + URLEncoder.encode(attribute, getCharset()) 
+                    + "&val=" + URLEncoder.encode(value, getCharset()));
+        } catch (UnsupportedEncodingException e) {
+            throw new BuildException
+                ("Invalid 'charset' attribute: " + getCharset());
+        }
     }
 }
index 4330936..a90febd 100644 (file)
@@ -19,6 +19,9 @@
 package org.apache.catalina.ant;
 
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
 import org.apache.tools.ant.BuildException;
 
 
@@ -64,7 +67,13 @@ public class ResourcesTask extends AbstractCatalinaTask {
 
         super.execute();
         if (type != null) {
-            execute("/resources?type=" + type);
+            try {
+                execute("/resources?type=" +
+                        URLEncoder.encode(type, getCharset()));
+            } catch (UnsupportedEncodingException e) {
+                throw new BuildException
+                    ("Invalid 'charset' attribute: " + getCharset());
+            }
         } else {
             execute("/resources");
         }
index 85f9023..7564a7f 100644 (file)
@@ -19,6 +19,9 @@
 package org.apache.catalina.ant;
 
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
 import org.apache.tools.ant.BuildException;
 
 
@@ -66,7 +69,13 @@ public class UndeployTask extends AbstractCatalinaTask {
                 ("Must specify 'path' attribute");
         }
 
-        execute("/undeploy?path=" + this.path);
+        try {
+            execute("/undeploy?path=" +
+                    URLEncoder.encode(this.path, getCharset()));
+        } catch (UnsupportedEncodingException e) {
+            throw new BuildException
+                ("Invalid 'charset' attribute: " + getCharset());
+        }
     }
 
 
index b255c37..bc38814 100644 (file)
   General, Catalina, Coyote, Jasper, Cluster, Web applications, Extras, Tribes,
   Other
 -->
+<section name="Tomcat 7.0.10 (markt)">
+  <subsection name="Catalina">
+    <changelog>
+      <fix>
+        <bug>28852</bug>: Add URL encoding where missing to parameters in URLs
+        presented by Ant tasks to the Manager application. Based on a patch by
+        Stephane Bailliez. (mark) 
+      </fix>
+    </changelog>
+  </subsection>
+</section>
 <section name="Tomcat 7.0.9 (markt)">
   <subsection name="Catalina">
     <changelog>