Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

Commit

Permalink
Bugfix: Work Item GH-384 - DOM loadHTMLFile() failing with options fl…
Browse files Browse the repository at this point in the history
…ags when using PHP < 5.4.0

Additional check that libxml is running at an appropriate version by testing if libxml flag value constants are defined
  • Loading branch information
MarkBaker committed Sep 5, 2014
1 parent 57ce19d commit f77d3d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Classes/PHPExcel/Reader/HTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
// Create a new DOM object
$dom = new DOMDocument;
// Reload the HTML file into the DOM object
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
if ((version_compare(PHP_VERSION, '5.4.0') >= 0) && defined(LIBXML_DTDLOAD)) {
$loaded = $dom->loadHTMLFile($pFilename, PHPExcel_Settings::getLibXmlLoaderOptions());
} else {
$loaded = $dom->loadHTMLFile($pFilename);
Expand Down
12 changes: 8 additions & 4 deletions Classes/PHPExcel/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,12 @@ public static function getPdfRendererPath()
*/
public static function setLibXmlLoaderOptions($options = null)
{
if (is_null($options)) {
if (is_null($options) && defined(LIBXML_DTDLOAD)) {
$options = LIBXML_DTDLOAD | LIBXML_DTDATTR;
}
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
}
self::$_libXmlLoaderOptions = $options;
} // function setLibXmlLoaderOptions

Expand All @@ -378,10 +380,12 @@ public static function setLibXmlLoaderOptions($options = null)
*/
public static function getLibXmlLoaderOptions()
{
if (is_null(self::$_libXmlLoaderOptions)) {
if (is_null(self::$_libXmlLoaderOptions) && defined(LIBXML_DTDLOAD)) {
self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
}
@libxml_disable_entity_loader(self::$_libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
@libxml_disable_entity_loader(self::$_libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
}
return self::$_libXmlLoaderOptions;
} // function getLibXmlLoaderOptions
}
2 changes: 1 addition & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Planned for v1.8.1
- Bugfix: (MBaker) - Fix to ensure that current cell is maintained when executing formula calculations
- Bugfix: (MBaker) Work Item GH-350 - Keep/set the value on Reader _loadSheetsOnly as NULL, courtesy of Restless-ET
- Bugfix: (MBaker) Work Item CP18105 - Loading an Excel 2007 spreadsheet throws an "Autofilter must be set on a range of cells" exception
- Bugfix: (MBaker) - Fix to autoloader registration for backward compatibility with PHP 5.2.0 not accepting the prepend flag
- Bugfix: (MBaker) Work Item GH-388 - Fix to autoloader registration for backward compatibility with PHP 5.2.0 not accepting the prepend flag
- Bugfix: (MBaker) Work Item GH-384 - DOM loadHTMLFile() failing with options flags when using PHP < 5.4.0
- Bugfix: (MBaker) - Fix for percentage operator in formulae for BIFF Writer
- General: (MBaker) - Small performance improvement for autosize columns
Expand Down

0 comments on commit f77d3d1

Please sign in to comment.