Author: taher
Date: Thu Aug 9 09:58:21 2018 New Revision: 1837708 URL: http://svn.apache.org/viewvc?rev=1837708&view=rev Log: Backported fix from trunk for revision: 1837697 Modified: ofbiz/branches/release16.11/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java Modified: ofbiz/branches/release16.11/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java?rev=1837708&r1=1837707&r2=1837708&view=diff ============================================================================== --- ofbiz/branches/release16.11/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java (original) +++ ofbiz/branches/release16.11/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/XmlRpcEventHandler.java Thu Aug 9 09:58:21 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; @@ -39,15 +40,21 @@ import javax.servlet.http.HttpServletRes 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.XMLReader; +import org.xml.sax.SAXException; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.UtilValidate; import org.apache.ofbiz.entity.Delegator; @@ -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() { |
Free forum by Nabble | Edit this page |