Use is_xml instead of simplexml_load_string

Reason for the change is it was throwing and error. Also using regex is less resource intensive. Using this to determine the content type.
This commit is contained in:
FusionPBX 2023-06-16 11:16:22 -06:00 committed by GitHub
parent 4d54821119
commit ad34744272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 6 deletions

View File

@ -465,15 +465,14 @@
header("Content-Length: ".strlen($file_contents));
}
else {
$result = simplexml_load_string ($file_contents, 'SimpleXmlElement', LIBXML_NOERROR+LIBXML_ERR_FATAL+LIBXML_ERR_NONE);
if (false == $result) {
header("Content-Type: text/plain");
header("Content-Length: ".strval(strlen($file_contents)));
}
else {
if (is_xml($file_contents)) {
header("Content-Type: text/xml; charset=utf-8");
header("Content-Length: ".strlen($file_contents));
}
else {
header("Content-Type: text/plain");
header("Content-Length: ".strval(strlen($file_contents)));
}
}
}
echo $file_contents;