Skip to content

Commit c2cd0e6

Browse files
committed
Breaking Change When Loading External Images
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)`.
1 parent 5e3a6a8 commit c2cd0e6

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com)
6-
and this project adheres to [Semantic Versioning](https://semver.org). Thia is always true of the master branch. Some earlier branches, including the branch from which you are reading this file, remain supported and security fixes are applied to them; if the security fix represents a breaking change, it may have to be applied as a minor or patch version.
6+
and this project adheres to [Semantic Versioning](https://semver.org). This is always true of the master branch. Some earlier branches, including the branch from which you are reading this file, remain supported and security fixes are applied to them; if the security fix represents a breaking change, it may have to be applied as a minor or patch version.
7+
8+
## TBD - 1.30.0
9+
10+
### Breaking Changes
11+
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. This is a necessary change for security purposes. It unfortunately breaks Semantic Versioning for reasons described above; there is no way to start a new major version for this branch.
713

814
# 2025-07-23 - 1.29.12
915

src/PhpSpreadsheet/Reader/BaseReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ abstract class BaseReader implements IReader
5151
*
5252
* @var bool
5353
*/
54-
protected $allowExternalImages = true;
54+
protected $allowExternalImages = false;
5555

5656
/**
5757
* 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
@@ -4,12 +4,19 @@
44

55
use PhpOffice\PhpSpreadsheet\Exception as SpreadsheetException;
66
use PhpOffice\PhpSpreadsheet\IOFactory;
7+
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader;
78
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
89
use PhpOffice\PhpSpreadsheetTests\Reader\Utility\File;
910
use PHPUnit\Framework\TestCase;
1011

1112
class URLImageTest extends TestCase
1213
{
14+
public function testDefault(): void
15+
{
16+
$reader = new XlsxReader();
17+
self::assertFalse($reader->getAllowExternalImages());
18+
}
19+
1320
public function testURLImageSourceAllowed(): void
1421
{
1522
if (getenv('SKIP_URL_IMAGE_TEST') === '1') {

0 commit comments

Comments
 (0)