forked from PHPOffice/PhpSpreadsheet
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix PHPOffice#4316. A security patch white-listed the protocols that could be used in a hyperlink. This PR adds mailto to the list.
- Loading branch information
Showing
3 changed files
with
40 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Writer\Html; | ||
|
||
use PhpOffice\PhpSpreadsheet\Spreadsheet; | ||
use PhpOffice\PhpSpreadsheet\Writer\Html as HtmlWriter; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class MailtoTest extends TestCase | ||
{ | ||
public function testBadHyperlink(): void | ||
{ | ||
$spreadsheet = new Spreadsheet(); | ||
$worksheet = $spreadsheet->getActiveSheet(); | ||
$worksheet->setCellValue('A1', 'Mail Me!'); | ||
$worksheet->getCell('A1') | ||
->getHyperlink() | ||
->setUrl('mailto:[email protected]'); | ||
$worksheet->setCellValue('A2', 'Mail You!'); | ||
$worksheet->getCell('A2') | ||
->getHyperlink() | ||
->setTooltip('go ahead') | ||
->setUrl('mailto:[email protected]'); | ||
$writer = new HtmlWriter($spreadsheet); | ||
$html = $writer->generateHtmlAll(); | ||
self::assertStringContainsString('<a href="mailto:[email protected]">Mail Me!</a>', $html); | ||
self::assertStringContainsString('<a href="mailto:[email protected]" title="go ahead">Mail You!</a>', $html); | ||
$spreadsheet->disconnectWorksheets(); | ||
} | ||
} |
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