Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions src/PhpSpreadsheet/Reader/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,16 +632,6 @@ protected function processDomElement(DOMNode $element, Worksheet $sheet, int &$r
}
}

/**
* Make sure mb_convert_encoding returns string.
*
* @param mixed $result
*/
private static function ensureString($result): string
{
return is_string($result) ? $result : '';
}

/**
* Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
*
Expand All @@ -660,8 +650,8 @@ public function loadIntoExisting($filename, Spreadsheet $spreadsheet)
$dom = new DOMDocument();
// Reload the HTML file into the DOM object
try {
$convert = mb_convert_encoding($this->securityScanner->scanFile($filename), 'HTML-ENTITIES', 'UTF-8');
$loaded = $dom->loadHTML(self::ensureString($convert));
$convert = $this->securityScanner->scanFile($filename);
$loaded = $dom->loadHTML($convert);
} catch (Throwable $e) {
$loaded = false;
}
Expand All @@ -683,8 +673,8 @@ public function loadFromString($content, ?Spreadsheet $spreadsheet = null): Spre
$dom = new DOMDocument();
// Reload the HTML file into the DOM object
try {
$convert = mb_convert_encoding($this->securityScanner->scan($content), 'HTML-ENTITIES', 'UTF-8');
$loaded = $dom->loadHTML(self::ensureString($convert));
$convert = $this->securityScanner->scan($content);
$loaded = $dom->loadHTML($convert);
} catch (Throwable $e) {
$loaded = false;
}
Expand Down
7 changes: 1 addition & 6 deletions src/PhpSpreadsheet/Reader/Xlsx.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
[$workbookBasename, $xmlNamespaceBase] = $this->getWorkbookBaseName();
$drawingNS = self::REL_TO_DRAWING[$xmlNamespaceBase] ?? Namespaces::DRAWINGML;
$chartNS = self::REL_TO_CHART[$xmlNamespaceBase] ?? Namespaces::CHART;
$wbRels = $this->loadZip("xl/_rels/${workbookBasename}.rels", Namespaces::RELATIONSHIPS);
$wbRels = $this->loadZip("xl/_rels/{$workbookBasename}.rels", Namespaces::RELATIONSHIPS);
$theme = null;
$this->styleReader = new Styles();
foreach ($wbRels->Relationship as $relx) {
Expand Down Expand Up @@ -1849,11 +1849,6 @@ private static function getArrayItem($array, $key = 0)

private static function dirAdd($base, $add): string
{
$add = "$add";
if (substr($add, 0, 4) === '/xl/') {
$add = substr($add, 4);
}

return (string) preg_replace('~[^/]+/\.\./~', '', dirname($base) . "/$add");
}

Expand Down