1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fix GH-16523: FILTER_FLAG_HOSTNAME accepts ending hyphen
This commit is contained in:
Christoph M. Becker
2024-10-21 21:20:39 +02:00
3 changed files with 24 additions and 1 deletions

3
NEWS
View File

@@ -44,6 +44,9 @@ PHP NEWS
. Fixed bug GH-16397 (Segmentation fault when comparing FFI object).
(nielsdos)
- Filter:
. Fixed bug GH-16523 (FILTER_FLAG_HOSTNAME accepts ending hyphen). (cmb)
- GD:
. Fixed bug GH-16334 (imageaffine overflow on matrix elements).
(David Carlier)

View File

@@ -542,7 +542,7 @@ static int _php_filter_validate_domain(char * domain, size_t len, zend_long flag
/* Reset label length counter */
i = 1;
} else {
if (i > 63 || (hostname && *s != '-' && !isalnum((int)*(unsigned char *)s))) {
if (i > 63 || (hostname && (*s != '-' || *(s + 1) == '\0') && !isalnum((int)*(unsigned char *)s))) {
return 0;
}

View File

@@ -0,0 +1,20 @@
--TEST--
GH-16523 (FILTER_FLAG_HOSTNAME accepts ending hyphen)
--EXTENSIONS--
filter
--FILE--
<?php
$domains = [
'a-.bc.com',
'a.bc-.com',
'a.bc.com-',
];
foreach ($domains as $domain) {
var_dump(filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME));
}
?>
--EXPECT--
bool(false)
bool(false)
bool(false)