From 38284a69e7c9cfaf0ca3d23f2b3fc7cd5ed3044f Mon Sep 17 00:00:00 2001 From: Herwin Weststrate Date: Wed, 4 Sep 2024 17:40:10 +0200 Subject: [PATCH] Automatically detect the fastest XML parser This should use libxml2 if available, and fall back to rexml otherwise. Recent version of rexml have a tag limit to mitigate some DoS attacks, which can easily be reached with the verbosity of XML-RPC. --- lib/xmlrpc/config.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/xmlrpc/config.rb b/lib/xmlrpc/config.rb index bd13932..27ecdd3 100644 --- a/lib/xmlrpc/config.rb +++ b/lib/xmlrpc/config.rb @@ -15,7 +15,11 @@ module Config # # * XMLParser::REXMLStreamParser # * XMLParser::LibXMLStreamParser - DEFAULT_PARSER = XMLParser::REXMLStreamParser + begin + DEFAULT_PARSER = XMLParser::LibXMLStreamParser.new.class + rescue LoadError + DEFAULT_PARSER = XMLParser::REXMLStreamParser.new.class + end # enable tag ENABLE_NIL_CREATE = false