Skip to content

Commit ac4befd

Browse files
authored
Merge commit from fork
1 parent 95b4e32 commit ac4befd

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). Thia is a
99

1010
### Breaking Changes
1111

12-
- Nothing yet.
12+
- Images will be loaded from an external source (e.g. http://example.com/img.png) only if the reader is explicitly set to allow it via `$reader->setAllowExternalImages(true)`. We do not believe that loading of external images is a widely used feature.
1313

1414
### Added
1515

docs/references/features-cross-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@
10281028
6. <span id="footnote6">There is very limited support for reading styles from an Ods spreadsheet. Writing styles has better support, although Number Format is incomplete.</span>
10291029
7. <span id="footnote7">In most cases, Html reader processes only inline styles; styles provided by Css classes may be ignored.</span>
10301030
8. <span id="footnote8">Code must [opt in](../topics/recipes.md#array-formulas) to array output.</span>
1031-
9. <span id="footnote9">Starting with release 4.5, code can allow or not external images. In release 4.5 (and in earlier releases which do not offer an option), default is to allow it.</span>
1031+
9. <span id="footnote9">Use with caution - allowing external images may can subject the caller to security exploits. Starting with release 4.5.0 (also earlier releases 3.9.3, 2.3.10, 2.1.11, and 1.29.12), code can allow or not external images. In those starting releases, and in earlier releases which do not offer an option, default is to allow it. In release 5+ (and earlier supported versions 1.30+, 2.1.12+, 2.4+, and 3.10+), the default is to not allow it.</span>
10321032

10331033
## Writers
10341034

src/PhpSpreadsheet/Reader/BaseReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ abstract class BaseReader implements IReader
5252
* Improper specification of these within a spreadsheet
5353
* can subject the caller to security exploits.
5454
*/
55-
protected bool $allowExternalImages = true;
55+
protected bool $allowExternalImages = false;
5656

5757
/**
5858
* IReadFilter instance.

tests/PhpSpreadsheetTests/Reader/Html/HtmlImage2Test.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@
55
namespace PhpOffice\PhpSpreadsheetTests\Reader\Html;
66

77
use PhpOffice\PhpSpreadsheet\Exception as SpreadsheetException;
8+
use PhpOffice\PhpSpreadsheet\Reader\Html as HtmlReader;
89
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
910
use PHPUnit\Framework\Attributes\DataProvider;
1011
use PHPUnit\Framework\TestCase;
1112

1213
class HtmlImage2Test extends TestCase
1314
{
15+
public function testDefault(): void
16+
{
17+
$reader = new HtmlReader();
18+
self::assertFalse($reader->getAllowExternalImages());
19+
}
20+
1421
public function testCanInsertImageGoodProtocolAllowed(): void
1522
{
1623
if (getenv('SKIP_URL_IMAGE_TEST') === '1') {

tests/PhpSpreadsheetTests/Reader/Xlsx/URLImageTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@
66

77
use PhpOffice\PhpSpreadsheet\Exception as SpreadsheetException;
88
use PhpOffice\PhpSpreadsheet\IOFactory;
9+
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader;
910
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
1011
use PhpOffice\PhpSpreadsheetTests\Reader\Utility\File;
1112
use PHPUnit\Framework\TestCase;
1213

1314
class URLImageTest extends TestCase
1415
{
16+
public function testDefault(): void
17+
{
18+
$reader = new XlsxReader();
19+
self::assertFalse($reader->getAllowExternalImages());
20+
}
21+
1522
public function testURLImageSourceAllowed(): void
1623
{
1724
if (getenv('SKIP_URL_IMAGE_TEST') === '1') {

0 commit comments

Comments
 (0)