Skip to content

Commit c26e766

Browse files
committed
Restore 2 Disabled Tests
1 parent e04ed22 commit c26e766

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/PhpSpreadsheet/Reader/Xlsx.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
14161416
);
14171417
if (isset($images[$linkImageKey])) {
14181418
$url = str_replace('xl/drawings/', '', $images[$linkImageKey]);
1419-
$objDrawing->setPath($url);
1419+
$objDrawing->setPath($url, false);
14201420
}
14211421
if ($objDrawing->getPath() === '') {
14221422
continue;
@@ -1509,7 +1509,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
15091509
);
15101510
if (isset($images[$linkImageKey])) {
15111511
$url = str_replace('xl/drawings/', '', $images[$linkImageKey]);
1512-
$objDrawing->setPath($url);
1512+
$objDrawing->setPath($url, false);
15131513
}
15141514
if ($objDrawing->getPath() === '') {
15151515
continue;

src/PhpSpreadsheet/Worksheet/Drawing.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ public function setPath(string $path, bool $verifyFile = true, ?ZipArchive $zip
109109
}
110110
// Implicit that it is a URL, rather store info than running check above on value in other places.
111111
$this->isUrl = true;
112-
$imageContents = @file_get_contents($path);
112+
$ctx = null;
113+
// https://github.com/php/php-src/issues/16023
114+
if (str_starts_with($path, 'https:')) {
115+
$ctx = stream_context_create(['ssl' => ['crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT]]);
116+
}
117+
$imageContents = @file_get_contents($path, false, $ctx);
113118
if ($imageContents !== false) {
114119
$filePath = tempnam(sys_get_temp_dir(), 'Drawing');
115120
if ($filePath) {

tests/PhpSpreadsheetTests/Reader/Xlsx/URLImageTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
class URLImageTest extends TestCase
1414
{
15-
// https://github.com/readthedocs/readthedocs.org/issues/11615
16-
public function xtestURLImageSource(): void
15+
public function testURLImageSource(): void
1716
{
1817
if (getenv('SKIP_URL_IMAGE_TEST') === '1') {
1918
self::markTestSkipped('Skipped due to setting of environment variable');
@@ -41,6 +40,10 @@ public function xtestURLImageSource(): void
4140
self::assertNotFalse($mimeType);
4241
$extension = File::mime2ext($mimeType);
4342
self::assertSame('png', $extension);
43+
self::assertSame(IMAGETYPE_PNG, $drawing->getType());
44+
self::assertSame(84, $drawing->getWidth());
45+
self::assertSame(44, $drawing->getHeight());
46+
$spreadsheet->disconnectWorksheets();
4447
}
4548
}
4649

@@ -56,6 +59,7 @@ public function xtestURLImageSourceNotFound(): void
5659
$worksheet = $spreadsheet->getActiveSheet();
5760
$collection = $worksheet->getDrawingCollection();
5861
self::assertCount(0, $collection);
62+
$spreadsheet->disconnectWorksheets();
5963
}
6064

6165
public function testURLImageSourceBadProtocol(): void

0 commit comments

Comments
 (0)