Module: sip-router
Branch: master
Commit: 238635d54eff8a176cfaf1fe26322b7de86fdac1
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=238635d…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Sep 23 12:59:56 2009 +0200
xmlrpc(s): escape CR in replies
- escape CR ('\r') in replies: each '\r' is replaced with &xD;
- added new parameter: escape_cr which controls CR escaping: if on
(default) CR in replies are escaped (according to the xml spec),
if off, they are not (which in most cases would result in the
xmlrpc client ignoring them).
---
modules_s/xmlrpc/xmlrpc.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/modules_s/xmlrpc/xmlrpc.c b/modules_s/xmlrpc/xmlrpc.c
index f386a88..34106bc 100644
--- a/modules_s/xmlrpc/xmlrpc.c
+++ b/modules_s/xmlrpc/xmlrpc.c
@@ -392,6 +392,8 @@ static int xmlrpc_route_no=DEFAULT_RT;
/* if set, try autoconverting to the requested type if possible
(e.g. convert 1 to "1" if string is requested) */
static int autoconvert=0;
+/* in replies, escape CR to 
 (according to the xml specs) */
+static int escape_cr=1; /* default on */
/*
@@ -410,6 +412,7 @@ static cmd_export_t cmds[] = {
static param_export_t params[] = {
{"route", PARAM_STRING, &xmlrpc_route},
{"autoconversion", PARAM_INT, &autoconvert},
+ {"escape_cr", PARAM_INT, &escape_cr},
{0, 0, 0}
};
@@ -430,6 +433,7 @@ struct module_exports exports = {
#define ESC_LT "<"
#define ESC_AMP "&"
+#define ESC_CR "
"
static void clean_context(rpc_ctx_t* ctx);
@@ -483,6 +487,14 @@ static int add_xmlrpc_reply_esc(struct xmlrpc_reply* reply, str*
text)
reply->body.len += sizeof(ESC_AMP) - 1;
break;
+ case '\r':
+ if (likely(escape_cr)){
+ memcpy(reply->body.s + reply->body.len, ESC_CR,
+ sizeof(ESC_CR) - 1);
+ reply->body.len += sizeof(ESC_CR) - 1;
+ break;
+ }
+ /* no break */
default:
reply->body.s[reply->body.len] = text->s[i];
reply->body.len++;