Skip to content

Commit

Permalink
mi_xmlrpc_ng: unescape xml strings
Browse files Browse the repository at this point in the history
 - related to bug #537
  • Loading branch information
ovidiusas committed Jun 11, 2015
1 parent f6386ca commit 8450630
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion modules/mi_xmlrpc_ng/http_fnc.c
Expand Up @@ -418,6 +418,7 @@ struct mi_root* mi_xmlrpc_http_run_mi_cmd(const str* arg,
xmlNodePtr value_node;
xmlNodePtr string_node;
str val;
str esc_val = {NULL, 0};

//LM_DBG("arg [%p]->[%.*s]\n", arg->s, arg->len, arg->s);
doc = xmlParseMemory(arg->s, arg->len);
Expand Down Expand Up @@ -510,8 +511,17 @@ struct mi_root* mi_xmlrpc_http_run_mi_cmd(const str* arg,
goto xml_error;
}
LM_DBG("got string param [%.*s]\n", val.len, val.s);

esc_val.s = shm_malloc(val.len);
if (esc_val.s == NULL) {
free_mi_tree(mi_cmd);
goto xml_error;
}
esc_val.len = unescape_xml(esc_val.s, val.s, val.len);
LM_DBG("got escaped string param [%.*s]\n", esc_val.len, esc_val.s);

node = &mi_cmd->node;
if(!add_mi_node_child(node,0,NULL,0,val.s,val.len)){
if(!add_mi_node_child(node,0,NULL,0,esc_val.s,esc_val.len)){
LM_ERR("cannot add the child node to the tree\n");
free_mi_tree(mi_cmd);
goto xml_error;
Expand Down Expand Up @@ -542,10 +552,12 @@ struct mi_root* mi_xmlrpc_http_run_mi_cmd(const str* arg,

if (mi_cmd) free_mi_tree(mi_cmd);
if(doc)xmlFree(doc);doc=NULL;
if(esc_val.s);shm_free(esc_val.s);
return mi_rpl;

xml_error:
if(doc)xmlFree(doc);doc=NULL;
if(esc_val.s);shm_free(esc_val.s);
return NULL;
}

Expand Down

0 comments on commit 8450630

Please sign in to comment.