|
2 | 2 |
|
3 | 3 | namespace PhpOffice\PhpSpreadsheet\Writer;
|
4 | 4 |
|
| 5 | +use Composer\Pcre\Preg; |
5 | 6 | use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
6 | 7 | use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
7 | 8 | use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
@@ -646,13 +647,13 @@ private function writeImageInCell(string $coordinates): string
|
646 | 647 | $filename = $drawing->getPath();
|
647 | 648 |
|
648 | 649 | // Strip off eventual '.'
|
649 |
| - $filename = (string) preg_replace('/^[.]/', '', $filename); |
| 650 | + $filename = Preg::replace('/^[.]/', '', $filename); |
650 | 651 |
|
651 | 652 | // Prepend images root
|
652 | 653 | $filename = $this->getImagesRoot() . $filename;
|
653 | 654 |
|
654 | 655 | // Strip off eventual '.' if followed by non-/
|
655 |
| - $filename = (string) preg_replace('@^[.]([^/])@', '$1', $filename); |
| 656 | + $filename = Preg::replace('@^[.]([^/])@', '$1', $filename); |
656 | 657 |
|
657 | 658 | // Convert UTF8 data to PCDATA
|
658 | 659 | $filename = htmlspecialchars($filename, Settings::htmlEntityFlags());
|
@@ -1411,7 +1412,7 @@ private function generateRowCellData(Worksheet $worksheet, null|Cell|string $cel
|
1411 | 1412 |
|
1412 | 1413 | // Converts the cell content so that spaces occuring at beginning of each new line are replaced by
|
1413 | 1414 | // Example: " Hello\n to the world" is converted to " Hello\n to the world"
|
1414 |
| - $cellData = (string) preg_replace('/(?m)(?:^|\\G) /', ' ', $cellData); |
| 1415 | + $cellData = Preg::replace('/(?m)(?:^|\\G) /', ' ', $cellData); |
1415 | 1416 |
|
1416 | 1417 | // convert newline "\n" to '<br>'
|
1417 | 1418 | $cellData = nl2br($cellData);
|
@@ -1599,9 +1600,9 @@ private function generateRow(Worksheet $worksheet, array $values, int $row, stri
|
1599 | 1600 | if ($worksheet->hyperlinkExists($coordinate) && !$worksheet->getHyperlink($coordinate)->isInternal()) {
|
1600 | 1601 | $url = $worksheet->getHyperlink($coordinate)->getUrl();
|
1601 | 1602 | $urlDecode1 = html_entity_decode($url, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
1602 |
| - $urlTrim = preg_replace('/^\\s+/u', '', $urlDecode1) ?? $urlDecode1; |
1603 |
| - $parseScheme = preg_match('/^([\\w\\s]+):/u', strtolower($urlTrim), $matches); |
1604 |
| - if ($parseScheme === 1 && !in_array($matches[1], ['http', 'https', 'file', 'ftp', 'mailto', 's3'], true)) { |
| 1603 | + $urlTrim = Preg::replace('/^\\s+/u', '', $urlDecode1); |
| 1604 | + $parseScheme = Preg::isMatch('/^([\\w\\s]+):/u', strtolower($urlTrim), $matches); |
| 1605 | + if ($parseScheme && !in_array($matches[1], ['http', 'https', 'file', 'ftp', 'mailto', 's3'], true)) { |
1605 | 1606 | $cellData = htmlspecialchars($url, Settings::htmlEntityFlags());
|
1606 | 1607 | } else {
|
1607 | 1608 | $tooltip = $worksheet->getHyperlink($coordinate)->getTooltip();
|
@@ -1755,7 +1756,7 @@ public static function formatColorStatic(string $value, string $format): string
|
1755 | 1756 | $matches = [];
|
1756 | 1757 |
|
1757 | 1758 | $color_regex = '/^\\[[a-zA-Z]+\\]/';
|
1758 |
| - if (preg_match($color_regex, $format, $matches)) { |
| 1759 | + if (Preg::isMatch($color_regex, $format, $matches)) { |
1759 | 1760 | $color = str_replace(['[', ']'], '', $matches[0]);
|
1760 | 1761 | $color = strtolower($color);
|
1761 | 1762 | }
|
|
0 commit comments