Skip to content

Commit

Permalink
Merge pull request #4 from AppsDevTeam/hotfix-isValidXmlString
Browse files Browse the repository at this point in the history
zrusena funkcia isValidXmlString($xmlString)
  • Loading branch information
thorewi committed Feb 27, 2017
2 parents b2ab53b + c3fc8f2 commit 53930ad
Showing 1 changed file with 3 additions and 24 deletions.
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;
}

}

0 comments on commit 53930ad

Please sign in to comment.