Skip to content

Commit 3078ea9

Browse files
committed
Additional Context Options for https, Restore Disabled Tests
Additional Context Options needed, at least sometimes, to read https images.
1 parent 1e78397 commit 3078ea9

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

src/PhpSpreadsheet/Worksheet/Drawing.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,17 @@ public function setPath(string $path, bool $verifyFile = true, ?ZipArchive $zip
112112
$ctx = null;
113113
// https://github.com/php/php-src/issues/16023
114114
if (str_starts_with($path, 'https:')) {
115-
$ctx = stream_context_create(['ssl' => ['crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT]]);
115+
$ctx = stream_context_create([
116+
'ssl' => ['crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT],
117+
'http' => [
118+
'user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
119+
'header' => [
120+
'Connection: keep-alive',
121+
// accept header used by chrome without image/webp
122+
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
123+
],
124+
],
125+
]);
116126
}
117127
$imageContents = @file_get_contents($path, false, $ctx);
118128
if ($imageContents !== false) {

tests/PhpSpreadsheetTests/Calculation/Functions/Logical/XorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static function providerXOR(): array
1818
}
1919

2020
#[\PHPUnit\Framework\Attributes\DataProvider('providerXORLiteral')]
21-
public function xtestXORLiteral(mixed $expectedResult, string $formula): void
21+
public function testXORLiteral(mixed $expectedResult, float|string $formula): void
2222
{
2323
$sheet = $this->getSheet();
2424
$sheet->getCell('A1')->setValue("=XOR($formula)");

tests/PhpSpreadsheetTests/Reader/Html/HtmlImage2Test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class HtmlImage2Test extends TestCase
1212
{
13-
public function xtestCanInsertImageGoodProtocol(): void
13+
public function testCanInsertImageGoodProtocol(): void
1414
{
1515
if (getenv('SKIP_URL_IMAGE_TEST') === '1') {
1616
self::markTestSkipped('Skipped due to setting of environment variable');
@@ -31,7 +31,7 @@ public function xtestCanInsertImageGoodProtocol(): void
3131
self::assertEquals('A1', $drawing->getCoordinates());
3232
}
3333

34-
public function xtestCantInsertImageNotFound(): void
34+
public function testCantInsertImageNotFound(): void
3535
{
3636
if (getenv('SKIP_URL_IMAGE_TEST') === '1') {
3737
self::markTestSkipped('Skipped due to setting of environment variable');

tests/PhpSpreadsheetTests/Reader/Xlsx/URLImageTest.php

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

1313
class URLImageTest extends TestCase
1414
{
15-
public function xtestURLImageSource(): void
15+
public function testURLImageSource(): void
1616
{
1717
if (getenv('SKIP_URL_IMAGE_TEST') === '1') {
1818
self::markTestSkipped('Skipped due to setting of environment variable');
@@ -37,7 +37,7 @@ public function xtestURLImageSource(): void
3737
$spreadsheet->disconnectWorksheets();
3838
}
3939

40-
public function xtestURLImageSourceNotFound(): void
40+
public function testURLImageSourceNotFound(): void
4141
{
4242
if (getenv('SKIP_URL_IMAGE_TEST') === '1') {
4343
self::markTestSkipped('Skipped due to setting of environment variable');

0 commit comments

Comments
 (0)