summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-08-13 04:30:26 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-08-13 04:30:26 +0000
commite7fea90327419214531371543662056c1398470d (patch)
tree8b7642b5cac62994ff55f80e733dedbff22105bf /modules
parent3836a33d1c210a806c13f9bb172724394fb3fd80 (diff)
downloadampache-e7fea90327419214531371543662056c1398470d.tar.gz
ampache-e7fea90327419214531371543662056c1398470d.tar.bz2
ampache-e7fea90327419214531371543662056c1398470d.zip
new mpd mojo from rosensama and rperkins
Diffstat (limited to 'modules')
-rwxr-xr-xmodules/xmlrpc/xmlrpc.inc390
-rwxr-xr-xmodules/xmlrpc/xmlrpcs.inc49
2 files changed, 312 insertions, 127 deletions
diff --git a/modules/xmlrpc/xmlrpc.inc b/modules/xmlrpc/xmlrpc.inc
index bdb818e2..e8b6aedd 100755
--- a/modules/xmlrpc/xmlrpc.inc
+++ b/modules/xmlrpc/xmlrpc.inc
@@ -58,6 +58,7 @@
global $xmlrpcI4;
global $xmlrpcInt;
global $xmlrpcDouble;
+ global $xmlrpcBoolean;
global $xmlrpcString;
global $xmlrpcDateTime;
global $xmlrpcBase64;
@@ -99,6 +100,26 @@
$xmlrpcStruct => 3
);
+ $xmlrpc_valid_parents = array(
+ 'BOOLEAN' => array('VALUE'),
+ 'I4' => array('VALUE'),
+ 'INT' => array('VALUE'),
+ 'STRING' => array('VALUE'),
+ 'DOUBLE' => array('VALUE'),
+ 'DATETIME.ISO8601' => array('VALUE'),
+ 'BASE64' => array('VALUE'),
+ 'ARRAY' => array('VALUE'),
+ 'STRUCT' => array('VALUE'),
+ 'PARAM' => array('PARAMS'),
+ 'METHODNAME' => array('METHODCALL'),
+ 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'),
+ 'MEMBER' => array('STRUCT'),
+ 'NAME' => array('MEMBER'),
+ 'DATA' => array('ARRAY'),
+ 'FAULT' => array('METHODRESPONSE'),
+ 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT'),
+ );
+
$xmlEntities=array(
'amp' => '&',
'quot' => '"',
@@ -123,8 +144,9 @@
$xmlrpcstr['no_ssl']='No SSL support compiled in.';
$xmlrpcerr['curl_fail']=8;
$xmlrpcstr['curl_fail']='CURL error';
-
-
+ $xmlrpcerr['invalid_request']=15;
+ $xmlrpcstr['invalid_request']='Invalid request payload';
+
$xmlrpcerr['multicall_notstruct'] = 9;
$xmlrpcstr['multicall_notstruct'] = 'system.multicall expected struct';
$xmlrpcerr['multicall_nomethod'] = 10;
@@ -146,7 +168,7 @@
$xmlrpc_internalencoding='ISO-8859-1';
$xmlrpcName='XML-RPC for PHP';
- $xmlrpcVersion='1.1.1';
+ $xmlrpcVersion='1.2';
// let user errors start at 800
$xmlrpcerruser=800;
@@ -158,15 +180,14 @@
// used to store state during parsing
// quick explanation of components:
- // st - used to build up a string for evaluation
// ac - used to accumulate values
- // qt - used to decide if quotes are needed for evaluation
- // cm - used to denote struct or array (comma needed)
// isf - used to indicate a fault
// lv - used to indicate "looking for a value": implements
// the logic to allow values with no types to be strings
// params - used to store parameters in method calls
// method - used to store method name
+ // stack - array with genealogy of xml elements names:
+ // used to validate nesting of xmlrpc elements
$_xh=array();
@@ -517,38 +538,73 @@
function xmlrpc_se($parser, $name, $attrs)
{
- global $_xh, $xmlrpcDateTime, $xmlrpcString;
+ global $_xh, $xmlrpcDateTime, $xmlrpcString, $xmlrpc_valid_parents;
+
+ // if invalid xmlrpc already detected, skip all processing
+ if ($_xh[$parser]['isf'] < 2)
+ {
+
+ // check for correct element nesting
+ // top level element can only be of 2 types
+ if (count($_xh[$parser]['stack']) == 0)
+ {
+ if ($name != 'METHODRESPONSE' && $name != 'METHODCALL')
+ {
+ $_xh[$parser]['isf'] = 2;
+ $_xh[$parser]['isf_reason'] = 'missing top level xmlrpc element';
+ return;
+ }
+ }
+ else
+ {
+ // not top level element: see if parent is OK
+ if (!in_array($_xh[$parser]['stack'][0], $xmlrpc_valid_parents[$name]))
+ {
+ $_xh[$parser]['isf'] = 2;
+ $_xh[$parser]['isf_reason'] = "xmlrpc element $name cannot be child of {$_xh[$parser]['stack'][0]}";
+ return;
+ }
+ }
switch($name)
{
case 'STRUCT':
case 'ARRAY':
- $_xh[$parser]['st'].='array(';
- $_xh[$parser]['cm']++;
+ //$_xh[$parser]['st'].='array(';
+ //$_xh[$parser]['cm']++;
// this last line turns quoting off
// this means if we get an empty array we'll
// simply get a bit of whitespace in the eval
- $_xh[$parser]['qt']=0;
+ //$_xh[$parser]['qt']=0;
+
+ // create an empty array to hold child values, and push it onto appropriate stack
+ $cur_val = array();
+ $cur_val['values'] = array();
+ $cur_val['type'] = $name;
+ array_unshift($_xh[$parser]['valuestack'], $cur_val);
break;
+ case 'METHODNAME':
case 'NAME':
- $_xh[$parser]['st'].='"';
+ //$_xh[$parser]['st'].='"';
$_xh[$parser]['ac']='';
break;
case 'FAULT':
$_xh[$parser]['isf']=1;
break;
case 'PARAM':
- $_xh[$parser]['st']='';
- break;
+ //$_xh[$parser]['st']='';
+ // clear value, so we can check later if no value will passed for this param/member
+ $_xh[$parser]['value']=null;
+ break;
case 'VALUE':
- $_xh[$parser]['st'].='new xmlrpcval(';
- $_xh[$parser]['vt']=$xmlrpcString;
+ //$_xh[$parser]['st'].='new xmlrpcval(';
+ // look for a value: if this is still true by the
+ // time we reach the end tag for value then the type is string
+ // by implication
+ $_xh[$parser]['vt']='value';
$_xh[$parser]['ac']='';
- $_xh[$parser]['qt']=0;
+ //$_xh[$parser]['qt']=0;
$_xh[$parser]['lv']=1;
- // look for a value: if this is still 1 by the
- // time we reach the first data segment then the type is string
- // by implication and we need to add in a quote
break;
case 'I4':
case 'INT':
@@ -557,9 +613,18 @@
case 'DOUBLE':
case 'DATETIME.ISO8601':
case 'BASE64':
- $_xh[$parser]['ac']=''; // reset the accumulator
+ if ($_xh[$parser]['vt']!='value')
+ {
+ //two data elements inside a value: an error occurred!
+ $_xh[$parser]['isf'] = 2;
+ $_xh[$parser]['isf_reason'] = "$name element following a {$_xh[$parser]['vt']} element inside a single value";
+ return;
+ }
- if ($name=='DATETIME.ISO8601' || $name=='STRING')
+ // reset the accumulator
+ $_xh[$parser]['ac']='';
+
+ /*if ($name=='DATETIME.ISO8601' || $name=='STRING')
{
$_xh[$parser]['qt']=1;
if ($name=='DATETIME.ISO8601')
@@ -577,73 +642,120 @@
// at the end of the element we must check
// for data format errors.
$_xh[$parser]['qt']=0;
- }
+ }*/
break;
case 'MEMBER':
- $_xh[$parser]['ac']='';
+ //$_xh[$parser]['ac']='';
+ // avoid warnings later on if no NAME is found before VALUE inside
+ // a struct member predefining member name as NULL
+ $_xh[$parser]['valuestack'][0]['name'] = '';
+ // clear value, so we can check later if no value will passed for this param/member
+ $_xh[$parser]['value']=null;
break;
+ case 'DATA':
+ case 'METHODCALL':
+ case 'METHODRESPONSE':
+ case 'PARAMS':
+ // valid elements that add little to processing
+ break;
default:
+ /// INVALID ELEMENT: RAISE ISF so that it is later recognized!!!
+ $_xh[$parser]['isf'] = 2;
+ $_xh[$parser]['isf_reason'] = "found not-xmlrpc xml element $name";
break;
}
+ // Save current element name to stack, to validate nesting
+ array_unshift($_xh[$parser]['stack'], $name);
+
if ($name!='VALUE')
{
$_xh[$parser]['lv']=0;
}
+ }
}
function xmlrpc_ee($parser, $name)
{
- global $_xh,$xmlrpcTypes,$xmlrpcString;
+ global $_xh,$xmlrpcTypes,$xmlrpcString,$xmlrpcDateTime;
+
+ if ($_xh[$parser]['isf'] < 2)
+ {
+
+ // push this element name from stack
+ // NB: if XML validates, correct opening/closing is guaranteed and
+ // we do not have to check for $name == $curr_elem.
+ // we also checked for proper nesting at start of elements...
+ $curr_elem = array_shift($_xh[$parser]['stack']);
switch($name)
{
case 'STRUCT':
case 'ARRAY':
- if ($_xh[$parser]['cm'] && substr($_xh[$parser]['st'], -1) ==',')
- {
- $_xh[$parser]['st']=substr($_xh[$parser]['st'],0,-1);
- }
- $_xh[$parser]['st'].=')';
+ //if ($_xh[$parser]['cm'] && substr($_xh[$parser]['st'], -1) ==',')
+ //{
+ // $_xh[$parser]['st']=substr($_xh[$parser]['st'],0,-1);
+ //}
+ //$_xh[$parser]['st'].=')';
+
+ // fetch out of stack array of values, and promote it to current value
+ $cur_val = array_shift($_xh[$parser]['valuestack']);
+ $_xh[$parser]['value'] = $cur_val['values'];
+
$_xh[$parser]['vt']=strtolower($name);
- $_xh[$parser]['cm']--;
+ //$_xh[$parser]['cm']--;
break;
case 'NAME':
- $_xh[$parser]['st'].= $_xh[$parser]['ac'] . '" => ';
+ //$_xh[$parser]['st'].= $_xh[$parser]['ac'] . '" => ';
+ $_xh[$parser]['valuestack'][0]['name'] = $_xh[$parser]['ac'];
break;
case 'BOOLEAN':
- // special case here: we translate boolean 1 or 0 into PHP
- // constants true or false
- // NB: this simple checks helps a lot sanitizing input, ie no
- // security problems around here
- if ($_xh[$parser]['ac']=='1')
- {
- $_xh[$parser]['ac']='true';
- }
- else
- {
- $_xh[$parser]['ac']='false';
- }
- $_xh[$parser]['vt']=strtolower($name);
- // Drop through intentionally.
case 'I4':
case 'INT':
case 'STRING':
case 'DOUBLE':
case 'DATETIME.ISO8601':
case 'BASE64':
- if ($_xh[$parser]['qt']==1)
+ $_xh[$parser]['vt']=strtolower($name);
+ //if ($_xh[$parser]['qt']==1)
+ if ($name=='STRING')
{
// we use double quotes rather than single so backslashification works OK
- $_xh[$parser]['st'].='"'. $_xh[$parser]['ac'] . '"';
+ //$_xh[$parser]['st'].='"'. $_xh[$parser]['ac'] . '"';
+ $_xh[$parser]['value']=$_xh[$parser]['ac'];
+ }
+ elseif ($name=='DATETIME.ISO8601')
+ {
+ $_xh[$parser]['vt']=$xmlrpcDateTime;
+ $_xh[$parser]['value']=$_xh[$parser]['ac'];
}
- elseif ($_xh[$parser]['qt']==2)
+ elseif ($name=='BASE64')
{
- $_xh[$parser]['st'].='base64_decode("'. $_xh[$parser]['ac'] . '")';
+ //$_xh[$parser]['st'].='base64_decode("'. $_xh[$parser]['ac'] . '")';
+
+ ///@todo check for failure of base64 decoding / catch warnings
+ $_xh[$parser]['value']=base64_decode($_xh[$parser]['ac']);
}
elseif ($name=='BOOLEAN')
{
- $_xh[$parser]['st'].=$_xh[$parser]['ac'];
+ // special case here: we translate boolean 1 or 0 into PHP
+ // constants true or false
+ // NB: this simple checks helps a lot sanitizing input, ie no
+ // security problems around here
+ if ($_xh[$parser]['ac']=='1')
+ {
+ //$_xh[$parser]['ac']='true';
+ $_xh[$parser]['value']=true;
+ }
+ else
+ {
+ //$_xh[$parser]['ac']='false';
+ // log if receiveing something strange, even though we set the value to false anyway
+ if ($_xh[$parser]['ac']!='0')
+ error_log('XML-RPC: invalid value received in BOOLEAN: '.$_xh[$parser]['ac']);
+ $_xh[$parser]['value']=false;
+ }
+ //$_xh[$parser]['st'].=$_xh[$parser]['ac'];
}
elseif ($name=='DOUBLE')
{
@@ -654,12 +766,14 @@
// TODO: find a better way of throwing an error
// than this!
error_log('XML-RPC: non numeric value received in DOUBLE: '.$_xh[$parser]['ac']);
- $_xh[$parser]['st'].="'ERROR_NON_NUMERIC_FOUND'";
+ //$_xh[$parser]['st'].="'ERROR_NON_NUMERIC_FOUND'";
+ $_xh[$parser]['value']='ERROR_NON_NUMERIC_FOUND';
}
else
{
// it's ok, add it on
- $_xh[$parser]['st'].=(double)$_xh[$parser]['ac'];
+ //$_xh[$parser]['st'].=(double)$_xh[$parser]['ac'];
+ $_xh[$parser]['value']=(double)$_xh[$parser]['ac'];
}
}
else
@@ -671,21 +785,28 @@
// TODO: find a better way of throwing an error
// than this!
error_log('XML-RPC: non numeric value received in INT: '.$_xh[$parser]['ac']);
- $_xh[$parser]['st'].="'ERROR_NON_NUMERIC_FOUND'";
+ //$_xh[$parser]['st'].="'ERROR_NON_NUMERIC_FOUND'";
+ $_xh[$parser]['value']='ERROR_NON_NUMERIC_FOUND';
}
else
{
// it's ok, add it on
- $_xh[$parser]['st'].=(int)$_xh[$parser]['ac'];
+ //$_xh[$parser]['st'].=(int)$_xh[$parser]['ac'];
+ $_xh[$parser]['value']=(int)$_xh[$parser]['ac'];
}
}
$_xh[$parser]['ac']='';
- $_xh[$parser]['qt']=0;
+ //$_xh[$parser]['qt']=0;
$_xh[$parser]['lv']=3; // indicate we've found a value
break;
case 'VALUE':
- // deal with a string value
- if (strlen($_xh[$parser]['ac'])>0 &&
+ // This if() detects if no scalar was inside <VALUE></VALUE>
+ if ($_xh[$parser]['vt']=='value')
+ {
+ $_xh[$parser]['value']=$_xh[$parser]['ac'];
+ $_xh[$parser]['vt']=$xmlrpcString;
+ }
+ /*if (strlen($_xh[$parser]['ac'])>0 &&
$_xh[$parser]['vt']==$xmlrpcString)
{
$_xh[$parser]['st'].='"'. $_xh[$parser]['ac'] . '"';
@@ -704,44 +825,62 @@
if ($_xh[$parser]['cm'])
{
$_xh[$parser]['st'].=',';
- }
+ }*/
+
+ // build the xmlrpc val out of the data received, and substitute it
+ $temp = new xmlrpcval($_xh[$parser]['value'], $_xh[$parser]['vt']);
+ // check if we are inside an array or struct:
+ // if value just built is inside an array, let's move it into array on the stack
+ if (count($_xh[$parser]['valuestack']) && $_xh[$parser]['valuestack'][0]['type']=='ARRAY')
+ {
+ $_xh[$parser]['valuestack'][0]['values'][] = $temp;
+ } else {
+ $_xh[$parser]['value'] = $temp;
+ }
break;
case 'MEMBER':
$_xh[$parser]['ac']='';
- $_xh[$parser]['qt']=0;
+ //$_xh[$parser]['qt']=0;
+ // add to array in the stack the last element built
+ // unless no VALUE was found
+ if ($_xh[$parser]['value'])
+ $_xh[$parser]['valuestack'][0]['values'][$_xh[$parser]['valuestack'][0]['name']] = $_xh[$parser]['value'];
+ else
+ error_log('XML-RPC: missing VALUE inside STRUCT in received xml');
break;
case 'DATA':
$_xh[$parser]['ac']='';
- $_xh[$parser]['qt']=0;
+ //$_xh[$parser]['qt']=0;
break;
case 'PARAM':
- $_xh[$parser]['params'][]=$_xh[$parser]['st'];
+ //$_xh[$parser]['params'][]=$_xh[$parser]['st'];
+ if ($_xh[$parser]['value'])
+ $_xh[$parser]['params'][]=$_xh[$parser]['value'];
+ else
+ error_log('XML-RPC: missing VALUE inside PARAM in received xml');
break;
case 'METHODNAME':
$_xh[$parser]['method']=ereg_replace("^[\n\r\t ]+", '', $_xh[$parser]['ac']);
break;
- // BOOLEAN HAS BEEN ENUMERATED ABOVE!
- /*case 'BOOLEAN':
- // special case here: we translate boolean 1 or 0 into PHP
- // constants true or false
- if ($_xh[$parser]['ac']=='1')
- {
- $_xh[$parser]['ac']='true';
- }
- else
- {
- $_xh[$parser]['ac']='false';
- $_xh[$parser]['vt']=strtolower($name);
- }
- break;*/
+ case 'PARAMS':
+ case 'FAULT':
+ case 'METHODCALL':
+ case 'METHORESPONSE':
+ break;
default:
+ // End of INVALID ELEMENT!
+ // shall we add an assert here for unreachable code???
break;
}
+
// if it's a valid type name, set the type
- if (isset($xmlrpcTypes[strtolower($name)]))
+ /*if (isset($xmlrpcTypes[strtolower($name)]))
{
$_xh[$parser]['vt']=strtolower($name);
+ }*/
+
}
+
}
function xmlrpc_cd($parser, $data)
@@ -751,37 +890,48 @@
//if (ereg("^[\n\r \t]+$", $data)) return;
// print "adding [${data}]\n";
- if ($_xh[$parser]['lv']!=3)
+ // skip processing if xml fault already detected
+ if ($_xh[$parser]['isf'] < 2)
{
- // "lookforvalue==3" means that we've found an entire value
- // and should discard any further character data
- if ($_xh[$parser]['lv']==1)
+ if ($_xh[$parser]['lv']!=3)
{
- // if we've found text and we're just in a <value> then
- // turn quoting on, as this will be a string
- $_xh[$parser]['qt']=1;
- // and say we've found a value
- $_xh[$parser]['lv']=2;
- }
- if(!@isset($_xh[$parser]['ac']))
- {
- $_xh[$parser]['ac'] = '';
+ // "lookforvalue==3" means that we've found an entire value
+ // and should discard any further character data
+ if ($_xh[$parser]['lv']==1)
+ {
+ // if we've found text and we're just in a <value> then
+ // turn quoting on, as this will be a string
+ //$_xh[$parser]['qt']=1;
+ // and say we've found a value
+ $_xh[$parser]['lv']=2;
+ }
+ if(!@isset($_xh[$parser]['ac']))
+ {
+ $_xh[$parser]['ac'] = '';
+ }
+ //$_xh[$parser]['ac'].=str_replace('$', '\$', str_replace('"', '\"', str_replace(chr(92),$xmlrpc_backslash, $data)));
+ $_xh[$parser]['ac'].=$data;
}
- $_xh[$parser]['ac'].=str_replace('$', '\$', str_replace('"', '\"', str_replace(chr(92),$xmlrpc_backslash, $data)));
}
}
function xmlrpc_dh($parser, $data)
{
global $_xh, $xmlrpc_backslash;
- if (substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';')
+
+ // skip processing if xml fault already detected
+ if ($parser[$_xh]['isf'] < 2)
{
- if ($_xh[$parser]['lv']==1)
+ if (substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';')
{
- $_xh[$parser]['qt']=1;
- $_xh[$parser]['lv']=2;
+ if ($_xh[$parser]['lv']==1)
+ {
+ //$_xh[$parser]['qt']=1;
+ $_xh[$parser]['lv']=2;
+ }
+ //$_xh[$parser]['ac'].=str_replace('$', '\$', str_replace('"', '\"', str_replace(chr(92),$xmlrpc_backslash, $data)));
+ $_xh[$parser]['ac'].=$data;
}
- $_xh[$parser]['ac'].=str_replace('$', '\$', str_replace('"', '\"', str_replace(chr(92),$xmlrpc_backslash, $data)));
}
}
@@ -1327,6 +1477,8 @@
$_xh=array();
$_xh[$parser]=array();
$_xh[$parser]['headers'] = array();
+ $_xh[$parser]['stack'] = array();
+ $_xh[$parser]['valuestack'] = array();
// separate HTTP headers from data
if (ereg("^HTTP", $data))
@@ -1401,11 +1553,12 @@
if ($bd)
$data = substr($data, 0, $bd);
- $_xh[$parser]['st']='';
- $_xh[$parser]['cm']=0;
+ //$_xh[$parser]['st']='';
+ //$_xh[$parser]['cm']=0;
$_xh[$parser]['isf']=0;
+ $_xh[$parser]['isf_reason']=0;
$_xh[$parser]['ac']='';
- $_xh[$parser]['qt']='';
+ //$_xh[$parser]['qt']='';
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
// G. Giunta 2005/02/13: PHP internally uses ISO-8859-1, so we have to tell
@@ -1439,13 +1592,19 @@
return $r;
}
xml_parser_free($parser);
- if ($this->debug)
+
+ if ($_xh[$parser]['isf'] > 1)
{
- print "<PRE>---EVALING---[" .
- strlen($_xh[$parser]['st']) . " chars]---\n" .
- htmlspecialchars($_xh[$parser]['st']) . ";\n---END---</PRE>";
+ if ($this->debug)
+ {
+ ///@todo echo something for user?
+ }
+
+ $r = new xmlrpcresp(0, $xmlrpcerr['invalid_return'],
+ $xmlrpcstr['invalid_return'] . ' ' . $_xh[$parser]['isf_reason']);
}
- if (strlen($_xh[$parser]['st'])==0)
+ //else if (strlen($_xh[$parser]['st'])==0)
+ else if (!is_object($_xh[$parser]['value']))
{
// then something odd has happened
// and it's time to generate a client side error
@@ -1455,13 +1614,25 @@
}
else
{
- $allOK=0;
- @eval('$v=' . $_xh[$parser]['st'] . '; $allOK=1;');
- if (!$allOK)
+
+ if ($this->debug)
{
- $r = new xmlrpcresp(0, $xmlrpcerr['invalid_return'], $xmlrpcstr['invalid_return']);
+ //print "<PRE>---EVALING---[" .
+ //strlen($_xh[$parser]['st']) . " chars]---\n" .
+ //htmlspecialchars($_xh[$parser]['st']) . ";\n---END---</PRE>";
+ print "<PRE>---PARSED---\n" ;
+ var_dump($_xh[$parser]['value']);
+ print "\n---END---</PRE>";
}
- else
+
+ //$allOK=0;
+ //@eval('$v=' . $_xh[$parser]['st'] . '; $allOK=1;');
+ //if (!$allOK)
+ //{
+ // $r = new xmlrpcresp(0, $xmlrpcerr['invalid_return'], $xmlrpcstr['invalid_return']);
+ //}
+ //else
+ $v = $_xh[$parser]['value'];
if ($_xh[$parser]['isf'])
{
$errno_v = $v->structmem('faultCode');
@@ -1742,7 +1913,8 @@
@reset($t);
while(list($id,$cont) = @each($t))
{
- eval('$b->'.$id.' = $cont;');
+ //eval('$b->'.$id.' = $cont;');
+ @$b->$id = $cont;
}
}
// end contrib
diff --git a/modules/xmlrpc/xmlrpcs.inc b/modules/xmlrpc/xmlrpcs.inc
index c361fe39..080fcd3e 100755
--- a/modules/xmlrpc/xmlrpcs.inc
+++ b/modules/xmlrpc/xmlrpcs.inc
@@ -374,10 +374,13 @@
$parser = xml_parser_create($xmlrpc_defencoding);
$_xh[$parser]=array();
- $_xh[$parser]['st']='';
- $_xh[$parser]['cm']=0;
+ //$_xh[$parser]['st']='';
+ //$_xh[$parser]['cm']=0;
$_xh[$parser]['isf']=0;
+ $_xh[$parser]['isf_reason']='';
$_xh[$parser]['params']=array();
+ $_xh[$parser]['stack']=array();
+ $_xh[$parser]['valuestack'] = array();
$_xh[$parser]['method']='';
// decompose incoming XML into request structure
@@ -401,35 +404,45 @@
xml_parser_free($parser);
}
else
+ if ($_xh[$parser]['isf'])
{
xml_parser_free($parser);
+ $r=new xmlrpcresp(0,
+ $xmlrpcerr['invalid_request'],
+ $xmlrpcstr['invalid_request'] . ' ' . $_xh[$parser]['isf_reason']);
+ }
+ else
+ {
+ xml_parser_free($parser);
+
$m=new xmlrpcmsg($_xh[$parser]['method']);
// now add parameters in
$plist='';
- $allOK = 1;
+ //$allOK = 1;
for($i=0; $i<sizeof($_xh[$parser]['params']); $i++)
{
//print "<!-- " . $_xh[$parser]['params'][$i]. "-->\n";
$plist.="$i - " . $_xh[$parser]['params'][$i]. ";\n";
- $allOK = 0;
- @eval('$m->addParam(' . $_xh[$parser]['params'][$i]. '); $allOK=1;');
- if (!$allOK)
- {
- break;
- }
+ //$allOK = 0;
+ //@eval('$m->addParam(' . $_xh[$parser]['params'][$i]. '); $allOK=1;');
+ @$m->addParam($_xh[$parser]['params'][$i]);
+ //if (!$allOK)
+ //{
+ // break;
+ //}
}
// uncomment this to really see what the server's getting!
// xmlrpc_debugmsg($plist);
- if (!$allOK)
- {
- $r = new xmlrpcresp(0,
- $xmlrpcerr['incorrect_params'],
- $xmlrpcstr['incorrect_params'] . ": xml error in param " . $i);
- }
- else
- {
+ //if (!$allOK)
+ //{
+ // $r = new xmlrpcresp(0,
+ // $xmlrpcerr['incorrect_params'],
+ // $xmlrpcstr['incorrect_params'] . ": xml error in param " . $i);
+ //}
+ //else
+ //{
$r = $this->execute($m);
- }
+ //}
}
return $r;
}