You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is fixable, e.g. if we re looking for hostname, the last element after . should not be an hyphen. However implementation of these filters might not be necessarily "turing complete" more or less on purpose, let's see what @Girgias thinks.
/* The first and the last character of a label must be alphanumeric */
if (*(s+1) =='.'|| (hostname&& (!isalnum((int)*(unsigned char*)(s-1)) || !isalnum((int)*(unsigned char*)(s+1))))) {
return0;
}
/* Reset label length counter */
i=1;
} else {
if (i>63|| (hostname&&*s!='-'&& !isalnum((int)*(unsigned char*)s))) {
return0;
}
i++;
}
The if branch is for all labels but the last. The else branch is only for the last label, where it had been overlooked to cater to a hyphen at the end.
changed the title [-]FILTER_VALIDATE_DOMAIN / FILTER_FLAG_HOSTNAME accepts ending hyphen[/-][+]FILTER_FLAG_HOSTNAME accepts ending hyphen[/+]on Oct 21, 2024
Activity
devnexen commentedon Oct 21, 2024
It is fixable, e.g. if we re looking for hostname, the last element after
.should not be an hyphen. However implementation of these filters might not be necessarily "turing complete" more or less on purpose, let's see what @Girgias thinks.Girgias commentedon Oct 21, 2024
The filter extension is quite old, and I haven't looked much into it. IIRC the original author is @derickr and he might have more of an idea.
cmb69 commentedon Oct 21, 2024
cmb69 commentedon Oct 21, 2024
Oops, can be simplified:
devnexen commentedon Oct 21, 2024
Does it work with examples like
e-book.com?cmb69 commentedon Oct 21, 2024
Yeah, sure. See
php-src/ext/filter/logical_filters.c
Lines 535 to 550 in 65f8857
The if branch is for all labels but the last. The else branch is only for the last label, where it had been overlooked to cater to a hyphen at the end.
Fix phpGH-16523: FILTER_FLAG_HOSTNAME accepts ending hyphen
[-]FILTER_VALIDATE_DOMAIN / FILTER_FLAG_HOSTNAME accepts ending hyphen[/-][+]FILTER_FLAG_HOSTNAME accepts ending hyphen[/+]Fix GH-16523: FILTER_FLAG_HOSTNAME accepts ending hyphen
Merge branch 'PHP-8.2' into PHP-8.3
Merge branch 'PHP-8.3' into PHP-8.4
Merge branch 'PHP-8.4'