Re: Don't compare zero exponentials in strings as equal

From: Date: Fri, 19 Mar 2021 13:28:23 +0000
Subject: Re: Don't compare zero exponentials in strings as equal
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-113609@lists.php.net to get a copy of this message
On Wed, Mar 3, 2021 at 3:04 PM Nikita Popov <nikita.ppv@gmail.com> wrote:

> Hi internals,
>
> PHP's == comparison semantics for strings have a peculiar edge-case, where
> comparisons of the form "0e123" == "0e456" return true, because they are
> interpreted as floating point zero numbers. This is problematic, because
> strings of that form are usually not numbers, but hex-encoded hashes or
> similar.
>
> I'm wondering if it may make sense to special-case the comparison
> semantics to not consider strings of the form "0e[DIGITS]" equal, unless
> they are exactly equal (i.e., fall back to lexicographical if both sides of
> the comparison are zero exponentials).
>
> Here's a possible implementation: https://github.com/php/php-src/pull/6749
>
> Of course, the usual rule that you should always use === still holds, but
> this at least eliminates the most dangerous edge case.
>

So, I gather the consensus here is that we should leave this alone as a
lost cause?

Regards,
Nikita


Thread (16 messages)

« previous php.internals (#113609) next »