PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
← All changes | libraries/vendor/PhpSpreadsheet/Reader/Xml.php +10 -4 3.3.3 → 3.4 View file →
@@ -1,8 +1,9 @@
1 1 <?php
2 2
3 3 namespace TablePress\PhpOffice\PhpSpreadsheet\Reader;
4 4
5 +use TablePress\Composer\Pcre\Preg;
5 6 use DateTime;
6 7 use DateTimeZone;
7 8 use TablePress\PhpOffice\PhpSpreadsheet\Cell\AddressHelper;
8 9 use TablePress\PhpOffice\PhpSpreadsheet\Cell\AddressRange;
@@ -52,11 +53,16 @@
52 53 }
53 54
54 55 public static function unentity(string $contents): string
55 56 {
56 - $contents = preg_replace('/&(amp|lt|gt|quot|apos);/', "\u{fffe}\u{feff}\$1;", trim($contents)) ?? $contents;
57 + // fffe is invalid, replace with replacement char
58 + $contents = str_replace("\u{fffe}", "\u{fffd}", $contents);
59 + // use positive lookahead to "protect" valid xml entities
60 + $contents = Preg::replace('/&(?=(?:amp|lt|gt|quot|apos|#[0-9]+|#x[0-9a-fA-F]+);)/', "\u{fffe}", trim($contents));
61 + // now decode remaining html entities
57 62 $contents = html_entity_decode($contents, ENT_NOQUOTES | ENT_SUBSTITUTE | ENT_HTML401, 'UTF-8');
58 - $contents = str_replace("\u{fffe}\u{feff}", '&', $contents);
63 + // Escape remaining ampersands, restore those which were replaced with fffe
64 + $contents = str_replace(['&', "\u{fffe}"], ['&amp;', '&'], $contents);
59 65
60 66 return $contents;
61 67 }
62 68
@@ -431,9 +437,9 @@
431 437 $arrayRange = (string) $cell_ss['ArrayRange'];
432 438 $arrayRef = AddressHelper::convertFormulaToA1($arrayRange, $rowID, $columnIndex);
433 439 }
434 440
435 - if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
441 + if (!$this->readFilter->readCell($columnID, $rowID, $worksheetName)) {
436 442 continue;
437 443 }
438 444
439 445 if (isset($cell_ss['HRef'])) {
@@ -650,9 +656,9 @@
650 656 }
651 657 }
652 658 $rangeCalculated = false;
653 659 if (isset($xmlX->WorksheetOptions->Panes->Pane->RangeSelection)) {
654 - if (1 === preg_match('/^R(\d+)C(\d+):R(\d+)C(\d+)$/', (string) $xmlX->WorksheetOptions->Panes->Pane->RangeSelection, $selectionMatches)) {
660 + if (Preg::isMatch('/^R(\d+)C(\d+):R(\d+)C(\d+)$/', (string) $xmlX->WorksheetOptions->Panes->Pane->RangeSelection, $selectionMatches)) {
655 661 $selectedCell = Coordinate::stringFromColumnIndex((int) $selectionMatches[2])
656 662 . $selectionMatches[1]
657 663 . ':'
658 664 . Coordinate::stringFromColumnIndex((int) $selectionMatches[4])