From 73fed24459463869aa82308cc002ab50d29e0141 Mon Sep 17 00:00:00 2001 From: stickz Date: Mon, 30 Dec 2024 13:16:40 -0500 Subject: [PATCH] tinyxml2: Change from i4 to i8 We need to follow the same specification as xmlrpc-c until we deprecate it. It is breaking various software such as sonarr. We can't have xmlrpc using i8 and tinyxml2 using i4, while we allow both to be used. --- src/rpc/xmlrpc_tinyxml2.cc | 10 +++----- test/rpc/xmlrpc_test.cc | 2 +- test/rpc/xmlrpc_test_data.txt | 46 +++++++++++++++++------------------ 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/rpc/xmlrpc_tinyxml2.cc b/src/rpc/xmlrpc_tinyxml2.cc index 42ee55890..1c9f669d7 100644 --- a/src/rpc/xmlrpc_tinyxml2.cc +++ b/src/rpc/xmlrpc_tinyxml2.cc @@ -142,11 +142,7 @@ print_object_xml(const torrent::Object& obj, tinyxml2::XMLPrinter* printer) { printer->CloseElement(true); break; case torrent::Object::TYPE_VALUE: - if (obj.as_value() > ((torrent::Object::value_type)2 << 30) || obj.as_value() < -((torrent::Object::value_type)2 << 30)) { - printer->OpenElement("i8", true); - } else { - printer->OpenElement("i4", true); - } + printer->OpenElement("i8", true); printer->PushText(std::to_string(obj.as_value()).c_str()); printer->CloseElement(true); break; @@ -194,7 +190,7 @@ print_object_xml(const torrent::Object& obj, tinyxml2::XMLPrinter* printer) { printer->CloseElement(true); break; default: - printer->OpenElement("i4", true); + printer->OpenElement("i8", true); printer->PushText(0); printer->CloseElement(true); } @@ -320,7 +316,7 @@ print_xmlrpc_fault(int faultCode, std::string faultString, tinyxml2::XMLPrinter* printer->PushText("faultCode"); printer->CloseElement(true); printer->OpenElement("value", true); - printer->OpenElement("i4", true); + printer->OpenElement("i8", true); printer->PushText(faultCode); printer->CloseElement(true); printer->CloseElement(true); diff --git a/test/rpc/xmlrpc_test.cc b/test/rpc/xmlrpc_test.cc index a5c2932da..51120a11c 100644 --- a/test/rpc/xmlrpc_test.cc +++ b/test/rpc/xmlrpc_test.cc @@ -78,7 +78,7 @@ XmlrpcTest::test_invalid_utf8() { void XmlrpcTest::test_size_limit() { std::string input = "xmlrpc_reflect\xc3\x28"; - std::string expected = "faultCode-509faultStringContent size exceeds maximum XML-RPC limit"; + std::string expected = "faultCode-509faultStringContent size exceeds maximum XML-RPC limit"; std::string output; m_xmlrpc.set_size_limit(1); m_xmlrpc.process(input.c_str(), input.size(), [&output](const char* c, uint32_t l){ output.append(c, l); return true;}); diff --git a/test/rpc/xmlrpc_test_data.txt b/test/rpc/xmlrpc_test_data.txt index b1e0fc2ef..c7adb1053 100644 --- a/test/rpc/xmlrpc_test_data.txt +++ b/test/rpc/xmlrpc_test_data.txt @@ -18,9 +18,9 @@ xmlrpc_reflectZm9vYmFy foobar -# i4 ints -xmlrpc_reflect41 -41 +# i8 ints +xmlrpc_reflect41 +41 # i8 ints xmlrpc_reflect2247483647 @@ -43,37 +43,37 @@ # Simple struct -xmlrpc_reflectlowerBound18upperBound139 -lowerBound18upperBound139 +xmlrpc_reflectlowerBound18upperBound139 +lowerBound18upperBound139 # Invalid - missing method -no_such_method41 -faultCode-506faultStringmethod 'no_such_method' not defined +no_such_method41 +faultCode-506faultStringmethod 'no_such_method' not defined -# Invalid - i4 target -xmlrpc_reflect41 -faultCode-500faultStringinvalid parameters: target must be a string +# Invalid - i8 target +xmlrpc_reflect41 +faultCode-500faultStringinvalid parameters: target must be a string # Invalid - empty int tag -xmlrpc_reflect -faultCode-501faultStringunable to parse empty integer +xmlrpc_reflect +faultCode-501faultStringunable to parse empty integer # Invalid - empty int text -xmlrpc_reflect -faultCode-501faultStringunable to parse empty integer +xmlrpc_reflect +faultCode-501faultStringunable to parse empty integer # Invalid - broken XML -thodCall>test_a41faultCode-503faultStringError=XML_ERROR_PARSING_ELEMENT ErrorID=6 (0x6) Line number=1: XMLElement name=method +thodCall>test_a41faultCode-503faultStringError=XML_ERROR_PARSING_ELEMENT ErrorID=6 (0x6) Line number=1: XMLElement name=method -# Invalid - non-integer i4 -xmlrpc_reflectstring value -faultCode-501faultStringunable to parse integer value +# Invalid - non-integer i8 +xmlrpc_reflectstring value +faultCode-501faultStringunable to parse integer value -# Invalid - float i4 -xmlrpc_reflect3.14 -faultCode-501faultStringunable to parse integer value +# Invalid - float i8 +xmlrpc_reflect3.14 +faultCode-501faultStringunable to parse integer value # Invalid - non-boolean boolean xmlrpc_reflectstring value -faultCode-501faultStringunknown boolean value: string value +faultCode-501faultStringunknown boolean value: string value