-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport Html Writer Security Patches
- Loading branch information
Showing
8 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/PhpSpreadsheetTests/Writer/Html/BadCustomPropertyTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Writer\Html; | ||
|
||
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader; | ||
use PhpOffice\PhpSpreadsheet\Writer\Html as HtmlWriter; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class BadCustomPropertyTest extends TestCase | ||
{ | ||
public function testBadCustomProperty(): void | ||
{ | ||
$reader = new XlsxReader(); | ||
$infile = 'tests/data/Reader/XLSX/sec-q229.dontuse'; | ||
$spreadsheet = $reader->load($infile); | ||
$writer = new HtmlWriter($spreadsheet); | ||
$html = $writer->generateHtmlAll(); | ||
self::assertStringContainsString('<meta name="custom.string.custom_property"><img src=1 onerror=alert()>" content="test" />', $html); | ||
$spreadsheet->disconnectWorksheets(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
tests/PhpSpreadsheetTests/Writer/Html/BadHyperlinkBaseTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Writer\Html; | ||
|
||
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader; | ||
use PhpOffice\PhpSpreadsheet\Writer\Html as HtmlWriter; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class BadHyperlinkBaseTest extends TestCase | ||
{ | ||
public function testBadHyperlinkBase(): void | ||
{ | ||
$reader = new XlsxReader(); | ||
$infile = 'tests/data/Reader/XLSX/sec-p66w.dontuse'; | ||
$spreadsheet = $reader->load($infile); | ||
$writer = new HtmlWriter($spreadsheet); | ||
$html = $writer->generateHtmlAll(); | ||
self::assertStringContainsString('<base href=""><img src=1 onerror=alert()>" />', $html); | ||
$spreadsheet->disconnectWorksheets(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
tests/PhpSpreadsheetTests/Writer/Html/BadHyperlinkTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Writer\Html; | ||
|
||
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader; | ||
use PhpOffice\PhpSpreadsheet\Writer\Html as HtmlWriter; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class BadHyperlinkTest extends TestCase | ||
{ | ||
public function testBadHyperlink(): void | ||
{ | ||
$reader = new XlsxReader(); | ||
$infile = 'tests/data/Reader/XLSX/sec-j47r.dontuse'; | ||
$spreadsheet = $reader->load($infile); | ||
$writer = new HtmlWriter($spreadsheet); | ||
$html = $writer->generateHtmlAll(); | ||
self::assertStringContainsString("<td class=\"column0 style1 f\">jav\tascript:alert()</td>", $html); | ||
$spreadsheet->disconnectWorksheets(); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.