9
9
use PhpOffice \PhpSpreadsheet \Chart \Chart ;
10
10
use PhpOffice \PhpSpreadsheet \RichText \RichText ;
11
11
use PhpOffice \PhpSpreadsheet \RichText \Run ;
12
+ use PhpOffice \PhpSpreadsheet \Settings ;
12
13
use PhpOffice \PhpSpreadsheet \Shared \Drawing as SharedDrawing ;
13
14
use PhpOffice \PhpSpreadsheet \Shared \File ;
14
15
use PhpOffice \PhpSpreadsheet \Shared \Font as SharedFont ;
@@ -350,7 +351,9 @@ public function writeAllSheets()
350
351
351
352
private static function generateMeta ($ val , $ desc )
352
353
{
353
- return $ val ? (' <meta name=" ' . $ desc . '" content=" ' . htmlspecialchars ($ val ) . '" /> ' . PHP_EOL ) : '' ;
354
+ return $ val
355
+ ? (' <meta name=" ' . $ desc . '" content=" ' . htmlspecialchars ($ val , Settings::htmlEntityFlags ()) . '" /> ' . PHP_EOL )
356
+ : '' ;
354
357
}
355
358
356
359
/**
@@ -369,7 +372,7 @@ public function generateHTMLHeader($pIncludeStyles = false)
369
372
$ html .= ' <head> ' . PHP_EOL ;
370
373
$ html .= ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> ' . PHP_EOL ;
371
374
$ html .= ' <meta name="generator" content="PhpSpreadsheet, https://github.com/PHPOffice/PhpSpreadsheet" /> ' . PHP_EOL ;
372
- $ html .= ' <title> ' . htmlspecialchars ($ properties ->getTitle ()) . '</title> ' . PHP_EOL ;
375
+ $ html .= ' <title> ' . htmlspecialchars ($ properties ->getTitle (), Settings:: htmlEntityFlags () ) . '</title> ' . PHP_EOL ;
373
376
$ html .= self ::generateMeta ($ properties ->getCreator (), 'author ' );
374
377
$ html .= self ::generateMeta ($ properties ->getTitle (), 'title ' );
375
378
$ html .= self ::generateMeta ($ properties ->getDescription (), 'description ' );
@@ -672,7 +675,7 @@ private function writeImageInCell(Worksheet $pSheet, $coordinates)
672
675
$ filename = preg_replace ('@^[.]([^/])@ ' , '$1 ' , $ filename );
673
676
674
677
// Convert UTF8 data to PCDATA
675
- $ filename = htmlspecialchars ($ filename );
678
+ $ filename = htmlspecialchars ($ filename, Settings:: htmlEntityFlags () );
676
679
677
680
$ html .= PHP_EOL ;
678
681
$ imageData = self ::winFileToUrl ($ filename );
@@ -1301,15 +1304,15 @@ private function generateRowCellDataValueRich($cell, &$cellData): void
1301
1304
1302
1305
// Convert UTF8 data to PCDATA
1303
1306
$ cellText = $ element ->getText ();
1304
- $ cellData .= htmlspecialchars ($ cellText );
1307
+ $ cellData .= htmlspecialchars ($ cellText, Settings:: htmlEntityFlags () );
1305
1308
1306
1309
$ cellData .= $ cellEnd ;
1307
1310
1308
1311
$ cellData .= '</span> ' ;
1309
1312
} else {
1310
1313
// Convert UTF8 data to PCDATA
1311
1314
$ cellText = $ element ->getText ();
1312
- $ cellData .= htmlspecialchars ($ cellText );
1315
+ $ cellData .= htmlspecialchars ($ cellText, Settings:: htmlEntityFlags () );
1313
1316
}
1314
1317
}
1315
1318
}
@@ -1326,7 +1329,7 @@ private function generateRowCellDataValue($pSheet, $cell, &$cellData): void
1326
1329
[$ this , 'formatColor ' ]
1327
1330
);
1328
1331
if ($ cellData === $ origData ) {
1329
- $ cellData = htmlspecialchars ($ cellData ?? '' );
1332
+ $ cellData = htmlspecialchars ($ cellData ?? '' , Settings:: htmlEntityFlags () );
1330
1333
}
1331
1334
if ($ pSheet ->getParent ()->getCellXfByIndex ($ cell ->getXfIndex ())->getFont ()->getSuperscript ()) {
1332
1335
$ cellData = '<sup> ' . $ cellData . '</sup> ' ;
@@ -1491,7 +1494,7 @@ private function generateRow(Worksheet $pSheet, array $pValues, $pRow, $cellType
1491
1494
1492
1495
// Hyperlink?
1493
1496
if ($ pSheet ->hyperlinkExists ($ coordinate ) && !$ pSheet ->getHyperlink ($ coordinate )->isInternal ()) {
1494
- $ cellData = '<a href=" ' . htmlspecialchars ($ pSheet ->getHyperlink ($ coordinate )->getUrl ()) . '" title=" ' . htmlspecialchars ($ pSheet ->getHyperlink ($ coordinate )->getTooltip ()) . '"> ' . $ cellData . '</a> ' ;
1497
+ $ cellData = '<a href=" ' . htmlspecialchars ($ pSheet ->getHyperlink ($ coordinate )->getUrl (), Settings:: htmlEntityFlags ()) . '" title=" ' . htmlspecialchars ($ pSheet ->getHyperlink ($ coordinate )->getTooltip (), Settings:: htmlEntityFlags ()) . '"> ' . $ cellData . '</a> ' ;
1495
1498
}
1496
1499
1497
1500
// Should the cell be written or is it swallowed by a rowspan or colspan?
@@ -1671,7 +1674,7 @@ public function formatColor($pValue, $pFormat)
1671
1674
}
1672
1675
1673
1676
// convert to PCDATA
1674
- $ value = htmlspecialchars ($ pValue );
1677
+ $ value = htmlspecialchars ($ pValue, Settings:: htmlEntityFlags () );
1675
1678
1676
1679
// color span tag
1677
1680
if ($ color !== null ) {
0 commit comments