Module: sip-router
Branch: master
Commit: fbc6ce9c0792408877166a3e35b1c6cc2dc645e3
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=fbc6ce9…
Author: Jason Penton <jason.penton(a)smilecoms.com>
Committer: Jason Penton <jason.penton(a)smilecoms.com>
Date: Fri Aug 24 09:51:06 2012 +0200
xmlrpc: more correct re XMLRPC spec re. no type specified, defaults to string
- This will allow you to receive docs like <value>mystringvalue</value>
- instead of only allowing
<value><string>mystringvalue</string></value>
- according to spec if no type specified, assume string
- allows kamailio to receive messages from apache ws-xmlrpc which doesnt specify string
type
---
modules/xmlrpc/xmlrpc.c | 29 +++++++++++++++++++++++------
1 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/modules/xmlrpc/xmlrpc.c b/modules/xmlrpc/xmlrpc.c
index aa5d3aa..b840131 100644
--- a/modules/xmlrpc/xmlrpc.c
+++ b/modules/xmlrpc/xmlrpc.c
@@ -1126,6 +1126,7 @@ static time_t xmlrpc2time(const char* str)
/* xml value types */
enum xmlrpc_val_type{
XML_T_STR,
+ XML_T_TXT,
XML_T_INT,
XML_T_BOOL,
XML_T_DATE,
@@ -1142,6 +1143,8 @@ static enum xmlrpc_val_type xml_get_type(xmlNodePtr value)
{
if (!xmlStrcmp(value->name, BAD_CAST "string")){
return XML_T_STR;
+ } else if (!xmlStrcmp(value->name, BAD_CAST "text")) {
+ return XML_T_TXT;
} else if ( !xmlStrcmp(value->name, BAD_CAST "i4") ||
!xmlStrcmp(value->name, BAD_CAST "int")) {
return XML_T_INT;
@@ -1204,6 +1207,7 @@ static int get_int(int* val, struct xmlrpc_reply* reply,
break;
case XML_T_DOUBLE:
case XML_T_STR:
+ case XML_T_TXT:
if (flags & GET_X_AUTOCONV)
break;
case XML_T_ERR:
@@ -1211,8 +1215,10 @@ static int get_int(int* val, struct xmlrpc_reply* reply,
set_fault(reply, 400, "Invalid Parameter Type");
return -1;
}
-
- val_str = (char*)xmlNodeListGetString(doc, i4->xmlChildrenNode, 1);
+ if (type == XML_T_TXT)
+ val_str = (char*)i4->content;
+ else
+ val_str = (char*)xmlNodeListGetString(doc, i4->xmlChildrenNode, 1);
if (!val_str) {
if (!(flags & GET_X_NOREPLY))
set_fault(reply, 400, "Empty Parameter Value");
@@ -1223,6 +1229,7 @@ static int get_int(int* val, struct xmlrpc_reply* reply,
case XML_T_INT:
case XML_T_BOOL:
case XML_T_STR:
+ case XML_T_TXT:
/* Integer/bool conversion */
*val = strtol(val_str, &end_ptr, 10);
if (val_str==end_ptr)
@@ -1295,6 +1302,7 @@ static int get_double(double* val, struct xmlrpc_reply* reply,
case XML_T_BOOL:
case XML_T_DATE:
case XML_T_STR:
+ case XML_T_TXT:
if (flags & GET_X_AUTOCONV)
break;
case XML_T_ERR:
@@ -1302,8 +1310,10 @@ static int get_double(double* val, struct xmlrpc_reply* reply,
set_fault(reply, 400, "Invalid Parameter Type");
return -1;
}
-
- val_str = (char*)xmlNodeListGetString(doc, dbl->xmlChildrenNode, 1);
+ if (type == XML_T_TXT)
+ val_str = (char*)dbl->content;
+ else
+ val_str = (char*)xmlNodeListGetString(doc, dbl->xmlChildrenNode, 1);
if (!val_str) {
if (!(flags & GET_X_NOREPLY))
set_fault(reply, 400, "Empty Double Parameter");
@@ -1315,6 +1325,7 @@ static int get_double(double* val, struct xmlrpc_reply* reply,
case XML_T_INT:
case XML_T_BOOL:
case XML_T_STR:
+ case XML_T_TXT:
*val = strtod(val_str, &end_ptr);
if (val_str==end_ptr)
ret=-1;
@@ -1379,6 +1390,7 @@ static int get_string(char** val, struct xmlrpc_reply* reply,
type=xml_get_type(dbl);
switch(type){
case XML_T_STR:
+ case XML_T_TXT:
break;
case XML_T_INT:
case XML_T_BOOL:
@@ -1391,9 +1403,13 @@ static int get_string(char** val, struct xmlrpc_reply* reply,
set_fault(reply, 400, "Invalid Parameter Type");
return -1;
}
- val_str = (char*)xmlNodeListGetString(doc, dbl->xmlChildrenNode, 1);
+ if (type == XML_T_TXT)
+ val_str = (char*)dbl->content;
+ else
+ val_str = (char*)xmlNodeListGetString(doc, dbl->xmlChildrenNode, 1);
+
if (!val_str) {
- if (type==XML_T_STR){
+ if (type==XML_T_STR || type==XML_T_TXT){
*val = null_str;
return 0;
}else{
@@ -1405,6 +1421,7 @@ static int get_string(char** val, struct xmlrpc_reply* reply,
ret=0;
switch(type){
case XML_T_STR:
+ case XML_T_TXT:
if (flags & GET_X_LFLF2CRLF){
p=val_str;
while(*p){