From 3055b7272b1cc4d4099e639932d8b84ccef36a37 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 10 Jan 2015 15:37:49 -0500 Subject: Fix m_xmlrpc server configuration option --- modules/m_xmlrpc.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'modules/m_xmlrpc.cpp') diff --git a/modules/m_xmlrpc.cpp b/modules/m_xmlrpc.cpp index 36401b800..1d08bed43 100644 --- a/modules/m_xmlrpc.cpp +++ b/modules/m_xmlrpc.cpp @@ -162,11 +162,8 @@ class ModuleXMLRPC : public Module MyXMLRPCServiceInterface xmlrpcinterface; ModuleXMLRPC(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), - httpref("HTTPProvider", "httpd/main"), xmlrpcinterface(this, "xmlrpc") + xmlrpcinterface(this, "xmlrpc") { - if (!httpref) - throw ModuleException("Unable to find http reference, is m_httpd loaded?"); - httpref->RegisterPage(&xmlrpcinterface); } @@ -178,7 +175,12 @@ class ModuleXMLRPC : public Module void OnReload(Configuration::Conf *conf) anope_override { + if (httpref) + httpref->UnregisterPage(&xmlrpcinterface); this->httpref = ServiceReference("HTTPProvider", conf->GetModule(this)->Get("server", "httpd/main")); + if (!httpref) + throw ConfigException("Unable to find http reference, is m_httpd loaded?"); + httpref->RegisterPage(&xmlrpcinterface); } }; -- cgit From dc5039e994a9bcbc0a59591296a753659095fd5b Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 3 Feb 2015 18:42:35 -0500 Subject: Properly unescape xmlrpc --- modules/m_xmlrpc.cpp | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'modules/m_xmlrpc.cpp') diff --git a/modules/m_xmlrpc.cpp b/modules/m_xmlrpc.cpp index 1d08bed43..2fd900e61 100644 --- a/modules/m_xmlrpc.cpp +++ b/modules/m_xmlrpc.cpp @@ -53,6 +53,39 @@ class MyXMLRPCServiceInterface : public XMLRPCServiceInterface, public HTTPPage return ret; } + static Anope::string Unescape(const Anope::string &string) + { + Anope::string ret = string; + for (int i = 0; special[i].character.empty() == false; ++i) + if (!special[i].replace.empty()) + ret = ret.replace_all_cs(special[i].replace, special[i].character); + + for (size_t i, last = 0; (i = string.find("&#", last)) != Anope::string::npos;) + { + last = i + 1; + + size_t end = string.find(';', i); + if (end == Anope::string::npos) + break; + + Anope::string ch = string.substr(i + 2, end - (i + 2)); + + if (ch.empty()) + continue; + + long l; + if (!ch.empty() && ch[0] == 'x') + l = strtol(ch.substr(1).c_str(), NULL, 16); + else + l = strtol(ch.c_str(), NULL, 10); + + if (l > 0 && l < 256) + ret = ret.replace_all_cs("&#" + ch + ";", Anope::string(l)); + } + + return ret; + } + private: static bool GetData(Anope::string &content, Anope::string &tag, Anope::string &data) { @@ -98,8 +131,8 @@ class MyXMLRPCServiceInterface : public XMLRPCServiceInterface, public HTTPPage } while (istag && !content.empty()); - tag = prev; - data = cur; + tag = Unescape(prev); + data = Unescape(cur); return !istag && !data.empty(); } -- cgit From 474cd7a99b13a0779205096cb4df43582d9418e6 Mon Sep 17 00:00:00 2001 From: Sebastian Barfurth Date: Sat, 7 Mar 2015 19:05:41 +0100 Subject: Correct wrong XML response tag --- modules/m_xmlrpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/m_xmlrpc.cpp') diff --git a/modules/m_xmlrpc.cpp b/modules/m_xmlrpc.cpp index 2fd900e61..01300fbbb 100644 --- a/modules/m_xmlrpc.cpp +++ b/modules/m_xmlrpc.cpp @@ -179,10 +179,10 @@ class MyXMLRPCServiceInterface : public XMLRPCServiceInterface, public HTTPPage if (!request.id.empty()) request.reply("id", request.id); - Anope::string r = "\n\n" + request.name + "\n\n\n\n\n"; + Anope::string r = "\n\n" + request.name + "\n\n\n\n\n"; for (std::map::const_iterator it = request.get_replies().begin(); it != request.get_replies().end(); ++it) r += "\n" + it->first + "\n\n" + this->Sanitize(it->second) + "\n\n\n"; - r += "\n\n\n\n"; + r += "\n\n\n\n"; request.r.Write(r); } -- cgit From 36a4be7623decd47a6aed2c90b4933b3ed0a6802 Mon Sep 17 00:00:00 2001 From: Sebastian Barfurth Date: Wed, 18 Mar 2015 19:06:08 +0100 Subject: XML-RPC responses also don't have a methodName tag Following http://xmlrpc.scripting.com/spec.html --- modules/m_xmlrpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/m_xmlrpc.cpp') diff --git a/modules/m_xmlrpc.cpp b/modules/m_xmlrpc.cpp index 01300fbbb..dc80625f7 100644 --- a/modules/m_xmlrpc.cpp +++ b/modules/m_xmlrpc.cpp @@ -179,7 +179,7 @@ class MyXMLRPCServiceInterface : public XMLRPCServiceInterface, public HTTPPage if (!request.id.empty()) request.reply("id", request.id); - Anope::string r = "\n\n" + request.name + "\n\n\n\n\n"; + Anope::string r = "\n\n\n\n\n\n"; for (std::map::const_iterator it = request.get_replies().begin(); it != request.get_replies().end(); ++it) r += "\n" + it->first + "\n\n" + this->Sanitize(it->second) + "\n\n\n"; r += "\n\n\n\n"; -- cgit