Skip to content

Commit 0aaad46

Browse files
orlitzkynielsdos
authored andcommitted
Fix most external GD 2.3.3 compatibility
* ext/gd/tests/bug45799.phpt: tweak to work with external gd. The expected output from this test contains an extra newline with gd-2.3.3 from the system (Gentoo). Adding a whitespace wildcard takes care of it, and the test still passes with the bundled version of gd. * ext/gd/tests: external gd-2.3.3 compatibility. Support for the legacy "gd" image format was removed from gd-2.3.3 upstream: https://github.com/libgd/libgd/blob/master/CHANGELOG.md#233---2021-09-12 Several tests for the gd extension utilize that format, and naturally fail when gd-2.3.3 from the system is used. This commit skips those tests when the version of gd is at least 2.3.3. * ext/gd/tests/bug73159.phpt: skip with external gd >= 2.3.3 This test uses the imagegd2() function to check that libgd/libgd#289 is fixed. When an external gd without support for the "gd" format is used, no error is thrown, but a nonsense result is printed: this is normal. The corresponding upstream test is disabled in that situation; it's not expected to work. This commit skips the corresponding PHP test under the same circumstances to fix a test failure with external gd >= 2.3.3. * ext/gd/tests/bug73155.phpt: skip with external gd >= 2.3.3 This test uses the imagegd2() function to check that libgd/libgd#309 is fixed. When an external gd without support for the "gd" format is used, no error is thrown, but a nonsense result is printed: this is normal. The corresponding upstream test is disabled in that situation; it's not expected to work. This commit skips the corresponding PHP test under the same circumstances to fix a test failure with external gd >= 2.3.3. * ext/gd/tests/bug73157.phpt: skip with external gd >= 2.3.3 This test ensures that the third (chunk_size) parameter to imagegd2() is respected when a fourth parameter is also given. However, when an external gd without support for the "gd" format is used, the call to imagegd2() does not really work at all. It doesn't fail, but it produces an "image" with a nonsense chunk size. To avoid failures when an external gd >= 2.3.3 is used, we skip the test entirely in that case. * ext/gd/tests/bug77973.phpt: accept lowercase "Invalid" This test fails with an external gd because the test expects "Invalid" where upstream gd says "invalid". This commit tweaks the expected output to accept an arbitrary character in the i/I position. * ext/gd/tests/bug39780_extern.phpt: update for external gd-2.3.3. Since there are no CI runs with external gd, I can only assume that this test has fallen out-of-date due to changes in PHP itself. I've tweaked the expected output (only slightly) so that the test passes with both gd-2.3.2 and gd-2.3.3. * ext/gd/tests/bug66356.phpt: update expected output for external gd. Newer (external) versions of GD start their error messages with lowercase characters, whereas this test is expecting them in uppercase. A single-character wildcard now supports both formats. * ext/gd/tests/imagegd_truecolor.phpt: skip with external gd >= 2.3.3. This test uses the imagegd() function, but the "gd" format has been disabled by default in upstream gd-2.3.3. We still get some kind of image data back from the call to imagegd(), but its "signature", "truecolor", and "size" no longer match the expected values. This commit skips the test when an external gd >= 2.3.3 is used. * ext/gd/tests/createfromwbmp2_extern.phpt: update for external gd-2.3.3. * ext/gd/tests/libgd00086_extern.phpt: update for external gd-2.3.3. Since there are no CI runs with external gd, I can only assume that this test has fallen out-of-date due to changes in PHP itself. I've tweaked the expected output (only slightly) so that the test passes with both gd-2.3.2 and gd-2.3.3. * ext/gd/tests/bug77272.phpt: update expected output for external gd. Newer (external) versions of GD start their error messages with lowercase characters, whereas this test is expecting them in uppercase. A single-character wildcard now supports both formats. * ext/gd/tests/bug77479.phpt: update for newer external gd. This test fails with gd-2.3.3 (at least) due to minor capitalization and whitespace issues. We add some wildcards to account for the difference. Closes GH-11257. Closes GH-11262. Closes GH-11264. Closes GH-11280.
1 parent 849fdca commit 0aaad46

29 files changed

+129
-17
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ PHP NEWS
2222
- FTP:
2323
. Fix context option check for "overwrite". (JonasQuinten)
2424

25+
- GD:
26+
. Fix most of the external libgd test failures. (Michael Orlitzky)
27+
2528
- MBString:
2629
. Fix GH-11300 (license issue: restricted unicode license headers).
2730
(nielsdos)

ext/gd/tests/bug38212-mb.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Bug #38212 (Seg Fault on invalid imagecreatefromgd2part() parameters)
33
--EXTENSIONS--
44
gd
5+
--SKIPIF--
6+
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
?>
511
--FILE--
612
<?php
713
require __DIR__ . '/func.inc';

ext/gd/tests/bug38212.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Bug #38212 (Seg Fault on invalid imagecreatefromgd2part() parameters)
33
--EXTENSIONS--
44
gd
5+
--SKIPIF--
6+
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
?>
511
--FILE--
612
<?php
713
require __DIR__ . '/func.inc';

ext/gd/tests/bug39780_extern.phpt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ $im = imagecreatefrompng(__DIR__ . '/bug39780.png');
1313
var_dump($im);
1414
?>
1515
--EXPECTF--
16-
gd-png: fatal libpng error: Read Error: truncated data
17-
gd-png error: setjmp returns error condition 2
18-
Warning: imagecreatefrompng(): v%sbug39780.png" is not a valid PNG file in /%s on line %d
16+
Warning: imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncated data%win %s on line %d
17+
18+
Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition %d%win %s on line %d
19+
20+
Warning: imagecreatefrompng(): "%sbug39780.png" is not a valid PNG file in %s on line %d
1921
bool(false)

ext/gd/tests/bug41442.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Bug #41442 (imagegd2() under output control)
44
gd
55
--SKIPIF--
66
<?php
7+
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3.3', '>=')) {
8+
die("skip test requires GD 2.3.2 or older");
9+
}
10+
711
if (!function_exists("imagegd2")) {
812
die("skip GD2 support unavailable");
913
}

ext/gd/tests/bug45799.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ imagepng($img);
99
imagedestroy($img);
1010
?>
1111
--EXPECTF--
12-
Warning: imagepng(): gd-png error: no colors in palette in %s on line %d
12+
Warning: imagepng(): gd-png error: no colors in palette%win %s on line %d

ext/gd/tests/bug66356.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ Array
3838
[height] => 10
3939
)
4040

41-
Warning: imagecrop(): One parameter to a memory allocation multiplication is negative or zero, failing operation gracefully
41+
Warning: imagecrop(): %cne parameter to a memory allocation multiplication is negative or zero, failing operation gracefully
4242
in %s on line %d
4343
bool(false)
4444
object(GdImage)#2 (0) {
4545
}
4646
object(GdImage)#2 (0) {
4747
}
4848

49-
Warning: imagecrop(): Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
49+
Warning: imagecrop(): %croduct of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
5050
in %s on line %d
5151
bool(false)

ext/gd/tests/bug71912-mb.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ Bug #71912 (libgd: signedness vulnerability)
44
gd
55
--SKIPIF--
66
<?php
7+
if (!GD_BUNDLED) {
8+
if (version_compare(GD_VERSION, '2.2.0', '<')) {
9+
die("skip test requires GD 2.2.0 or higher");
10+
}
11+
if (version_compare(GD_VERSION, '2.3.3', '>=')) {
12+
die("skip test requires GD 2.3.2 or older");
13+
}
14+
}
715
if(!function_exists('imagecreatefromgd2')) die('skip imagecreatefromgd2() not available');
816
?>
917
--FILE--

ext/gd/tests/bug71912.phpt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ Bug #71912 (libgd: signedness vulnerability)
44
gd
55
--SKIPIF--
66
<?php
7-
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.0', '<')) {
8-
die("skip test requires GD 2.2.0 or higher");
7+
if (!GD_BUNDLED) {
8+
if (version_compare(GD_VERSION, '2.2.0', '<')) {
9+
die("skip test requires GD 2.2.0 or higher");
10+
}
11+
if (version_compare(GD_VERSION, '2.3.3', '>=')) {
12+
die("skip test requires GD 2.3.2 or older");
13+
}
914
}
1015
if(!function_exists('imagecreatefromgd2')) die('skip imagecreatefromgd2() not available');
1116
?>

ext/gd/tests/bug72339.phpt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ gd
55
--SKIPIF--
66
<?php
77
if (!function_exists("imagecreatefromgd2")) print "skip";
8-
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.2', '<')) {
9-
die("skip test requires GD 2.2.2 or higher");
8+
9+
if (!GD_BUNDLED) {
10+
if (version_compare(GD_VERSION, '2.2.2', '<')) {
11+
die("skip test requires GD 2.2.2 or higher");
12+
}
13+
if (version_compare(GD_VERSION, '2.3.3', '>=')) {
14+
die("skip test requires GD 2.3.2 or older");
15+
}
1016
}
1117
?>
1218
--FILE--

0 commit comments

Comments
 (0)