Don't rely on implicit string->int cast in comparison

PHP8 came with saner string to number comparisons.

In PHP8, the empty string "" will not be cast to integer before
the comparison. And so literally 0 == "" is false. Previously it
will be cast, so the eventual comparison was 0 == 0, which is true.

Bug: T272250
Change-Id: Ic280467e520840d45cbd172476252c6de5164100
This commit is contained in:
Ammarpad 2021-01-18 07:45:10 +01:00
parent e34218f50d
commit 995e2a0eed

View file

@ -115,7 +115,7 @@ class Cookie {
// Don't allow cookies for "co.uk" or "gov.uk", etc, but allow "supermarket.uk"
if ( strrpos( $domain, "." ) - strlen( $domain ) == -3 ) {
if ( ( count( $dc ) == 2 && strlen( $dc[0] ) <= 2 )
|| ( count( $dc ) == 3 && strlen( $dc[0] ) == "" && strlen( $dc[1] ) <= 2 ) ) {
|| ( count( $dc ) == 3 && strlen( $dc[0] ) == 0 && strlen( $dc[1] ) <= 2 ) ) {
return false;
}
if ( ( count( $dc ) == 2 || ( count( $dc ) == 3 && $dc[0] == '' ) )