MDL-16289 - actually unpack xmlrpc errors rather than just whinge the payload is unencrypted

This commit is contained in:
mjollnir_
2008-09-02 14:11:53 +00:00
parent e6b8473257
commit a5248bee7b
2 changed files with 32 additions and 3 deletions
+3 -2
View File
@@ -249,8 +249,9 @@ class mnet_xmlrpc_client {
}
} else {
if (! empty($crypt_parser->error)) {
if (! empty($crypt_parser->remoteerror)) {
$this->error[] = '4: remote server error: ' . $crypt_parser->remoteerror;
} else if (! empty($crypt_parser->error)) {
$crypt_parser_error = $crypt_parser->error[0];
$message = '3:XML Parse error in payload: '.$crypt_parser_error['string']."\n";
+29 -1
View File
@@ -43,6 +43,8 @@ class mnet_encxml_parser {
$this->payload_encrypted = false;
$this->cipher = array();
$this->error = array();
$this->remoteerror = null;
$this->errorstarted = false;
return true;
}
@@ -113,6 +115,10 @@ class mnet_encxml_parser {
}
}
if (!empty($this->remoteerror)) {
return false;
}
if (count($this->cipher) > 0) {
$this->cipher = array_values($this->cipher);
$this->payload_encrypted = true;
@@ -166,6 +172,8 @@ class mnet_encxml_parser {
$this->cipher[$this->tag_number] = '';
$handler = 'parse_cipher';
break;
case 'FAULT':
$handler = 'parse_fault';
default:
break;
}
@@ -264,7 +272,27 @@ class mnet_encxml_parser {
* @return bool True
*/
function discard_data($parser, $data) {
// Not interested
if (!$this->errorstarted) {
// Not interested
return true;
}
$data = trim($data);
if (isset($this->errorstarted->faultstringstarted) && !empty($data)) {
$this->remoteerror .= ', message: ' . $data;
} else if (isset($this->errorstarted->faultcodestarted)) {
$this->remoteerror = 'code: ' . $data;
unset($this->errorstarted->faultcodestarted);
} else if ($data == 'faultCode') {
$this->errorstarted->faultcodestarted = true;
} else if ($data == 'faultString') {
$this->errorstarted->faultstringstarted = true;
}
return true;
}
function parse_fault($parser, $data) {
$this->errorstarted = new StdClass;
return true;
}