php-src/ext/gd/tests/gh10344.phpt
Niels Dossche 4a48729438 Fix GH-10344: imagettfbbox(): Could not find/open font UNC path
libgd uses an incorrect absolute path check in gdft.c.
It checks if either the path starts with a '/' (only valid on Posix
btw), or whether it contains something of the form C:\ or C:/.
However, this overlooks the possibility of using UNC paths on Windows.
As we already do PHP-specific stuff with VCWD_ macros, use
IS_ABSOLUTE_PATH to check for an absolute path which will take into
account UNC paths as well.

Closes GH-13241.
2024-01-25 20:06:28 +01:00

29 lines
585 B
PHP

--TEST--
GH-10344 (imagettfbbox(): Could not find/open font UNC path)
--EXTENSIONS--
gd
--SKIPIF--
<?php
if (PHP_OS_FAMILY != 'Windows') {
die("skip windows only test");
}
if (!GD_BUNDLED) {
die("skip Not (yet) fixed in libgd itself");
}
if (!function_exists("imagettfbbox")) {
die("skip ttf support unavailable");
}
if (!is_readable("\\\\localhost\\c$\\Windows\\Fonts\\arial.ttf")) {
die("skip font not readable");
}
?>
--FILE--
<?php
$font = '\\\\localhost\\c$\\Windows\\Fonts\\arial.ttf';
var_dump(count(imagettfbbox(10, 0, $font, 'hello')));
?>
--EXPECT--
int(8)