svn commit: r1837707 - /ofbiz/ofbiz-framework/branches/release17.12/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1837707 - /ofbiz/ofbiz-framework/branches/release17.12/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java

Taher Alkhateeb
Author: taher
Date: Thu Aug  9 09:57:26 2018
New Revision: 1837707

URL: http://svn.apache.org/viewvc?rev=1837707&view=rev
Log:
Backported fix from trunk for revision: 1837697

Modified:
    ofbiz/ofbiz-framework/branches/release17.12/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java

Modified: ofbiz/ofbiz-framework/branches/release17.12/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/branches/release17.12/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java?rev=1837707&r1=1837706&r2=1837707&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/branches/release17.12/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java (original)
+++ ofbiz/ofbiz-framework/branches/release17.12/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java Thu Aug  9 09:57:26 2018
@@ -29,6 +29,7 @@ import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.Writer;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
@@ -52,15 +53,21 @@ import org.apache.ofbiz.webapp.control.C
 import org.apache.xmlrpc.XmlRpcException;
 import org.apache.xmlrpc.XmlRpcHandler;
 import org.apache.xmlrpc.XmlRpcRequest;
+import org.apache.xmlrpc.XmlRpcRequestConfig;
 import org.apache.xmlrpc.common.ServerStreamConnection;
 import org.apache.xmlrpc.common.XmlRpcHttpRequestConfig;
 import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl;
 import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig;
+import org.apache.xmlrpc.parser.XmlRpcRequestParser;
 import org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping;
 import org.apache.xmlrpc.server.XmlRpcHttpServer;
 import org.apache.xmlrpc.server.XmlRpcHttpServerConfig;
 import org.apache.xmlrpc.server.XmlRpcNoSuchHandlerException;
 import org.apache.xmlrpc.util.HttpUtil;
+import org.apache.xmlrpc.util.SAXParsers;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
 
 /**
  * XmlRpcEventHandler
@@ -265,6 +272,37 @@ public class XmlRpcEventHandler extends
         }
     }
 
+    protected XmlRpcRequest getRequest(final XmlRpcStreamRequestConfig pConfig, InputStream pStream)
+            throws XmlRpcException {
+        final XmlRpcRequestParser parser = new XmlRpcRequestParser(pConfig, getTypeFactory());
+        final XMLReader xr = SAXParsers.newXMLReader();
+        xr.setContentHandler(parser);
+        try {
+            xr.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+            xr.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+            xr.setFeature("http://xml.org/sax/features/external-general-entities", false);
+            xr.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+            xr.parse(new InputSource(pStream));
+        } catch (SAXException | IOException e) {
+            throw new XmlRpcException("Failed to parse / read XML-RPC request: " + e.getMessage(), e);
+        }
+        final List<?> params = parser.getParams();
+        return new XmlRpcRequest() {
+            public XmlRpcRequestConfig getConfig() {
+                return pConfig;
+            }
+            public String getMethodName() {
+                return parser.getMethodName();
+            }
+            public int getParameterCount() {
+                return params == null ? 0 : params.size();
+            }
+            public Object getParameter(int pIndex) {
+                return params.get(pIndex);
+            }
+        };
+    }
+
     class ServiceRpcHandler extends AbstractReflectiveHandlerMapping implements XmlRpcHandler {
 
         public ServiceRpcHandler() {