Skip to content
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 3 additions & 24 deletions src/SmartEmailing.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,10 @@ protected function callSmartemailingApiWithCurl($data) {
return $this->getErrorXml($e->getCode(), $e->getMessage());
}

$xml = simplexml_load_string($response);

if ($this->isValidXmlString($response)) {
return new \SimpleXMLElement($response);

if ($xml !== FALSE) {
return $xml;
} else {
return $this->getErrorXml('500', 'Unknown Smartemailing API error.');
}
Expand All @@ -319,25 +319,4 @@ public function getErrorXml($code, $message) {
return $xml;
}


/**
* check if xml string is valid
*
* @param string $xmlString
* @return bool
*/
protected function isValidXmlString($xmlString) {
libxml_use_internal_errors(TRUE);

$doc = simplexml_load_string($xmlString);

if (!$doc) {
$errors = libxml_get_errors();

return empty($errors);
}

return FALSE;
}

}