Skip to content

Commit 5e20d6d

Browse files
authored
Merge pull request #97 from mdeweerd/fix/xml-security
Improve security for lib_xml
2 parents d813bd6 + ff7b9ff commit 5e20d6d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

PSWebServiceLibrary.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,13 @@ protected function parseXML($response)
274274
if ($response != '') {
275275
libxml_clear_errors();
276276
libxml_use_internal_errors(true);
277-
$xml = simplexml_load_string(trim($response), 'SimpleXMLElement', LIBXML_NOCDATA);
277+
if (LIBXML_VERSION < 20900) {
278+
// Avoid load of external entities (security problem).
279+
// Required only if LIBXML_VERSION < 20900
280+
libxml_disable_entity_loader(true);
281+
}
282+
283+
$xml = simplexml_load_string(trim($response), 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
278284
if (libxml_get_errors()) {
279285
$msg = var_export(libxml_get_errors(), true);
280286
libxml_clear_errors();

0 commit comments

Comments
 (0)