Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84022 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1887 invoked from network); 27 Feb 2015 15:53:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Feb 2015 15:53:39 -0000 Authentication-Results: pb1.pair.com header.from=damz@damz.org; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=damz@damz.org; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain damz.org designates 74.125.82.43 as permitted sender) X-PHP-List-Original-Sender: damz@damz.org X-Host-Fingerprint: 74.125.82.43 mail-wg0-f43.google.com Received: from [74.125.82.43] ([74.125.82.43:35422] helo=mail-wg0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B1/98-32582-10390F45 for ; Fri, 27 Feb 2015 10:53:38 -0500 Received: by wggz12 with SMTP id z12so21302564wgg.2 for ; Fri, 27 Feb 2015 07:53:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=damz.org; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=3tsIPn2WKjLYvLZuzCpP7aRUJSUBLO2GOK0G7Z/ktPw=; b=h8TA8DWGxeHsuVr7q3UX65kILCCZ2V3/K/sTHzLHPlomloG8n4PqyQo9gwpQoDbzVB G5dhGmqcL82JmZFLMoShBz2fsGdAV1BslFiZr0CRdF/JQ/+SkwU4k+WWdh67yUiryMbl hArUw0dNpiKHcJiRcDhMx7Ew54/Zz3iWM5rVA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=3tsIPn2WKjLYvLZuzCpP7aRUJSUBLO2GOK0G7Z/ktPw=; b=iAM7tbwXcA95B4FjBiiRlV3zNFLv84ImCnnkj8sBsneTr7ONhs+AD5RTdiMe7NKF9l 6DHSD6tEpePg00UCap7k6EaWcBjfH5bOnGS5lSWKoHwCFo9rvdf49Hj/phLhckvUb2ER dv+trbiOXbDajd3w1k9jndJkFsuuyRcGCtqm6YfiIXYwUABx7HSg0KGSiTILlqW2iUIZ Sdp6XBT4+TZEWGxTxbYL0ffMmv9B0Nq0CmVVFngxKkHdFs+istUeU0XMw3crgaz99QKX Yql9PLHIUXRbmaMDD6Q5/WyDiXgmkFON7uZSM+YhGGtZJQ30AoAjJSmj/3uNBg/gE6zt NIBw== X-Gm-Message-State: ALoCoQkByVOlZgHlG3+6X+RPw1P3CoO66gqmNA8WWq53+R05/QgYcD9vDzwEeU65kPZNYO2uNc8a MIME-Version: 1.0 X-Received: by 10.194.172.35 with SMTP id az3mr29556998wjc.43.1425052413921; Fri, 27 Feb 2015 07:53:33 -0800 (PST) Received: by 10.28.181.131 with HTTP; Fri, 27 Feb 2015 07:53:33 -0800 (PST) X-Originating-IP: [78.126.234.166] In-Reply-To: <4ED7146272E04A47B986ED49E771E347D3111ACD63@Ikarus.ameusgmbh.intern> References: <4ED7146272E04A47B986ED49E771E347D3111ACD63@Ikarus.ameusgmbh.intern> Date: Fri, 27 Feb 2015 16:53:33 +0100 Message-ID: To: Christian Stoller Cc: Zeev Suraski , PHP internals Content-Type: multipart/alternative; boundary=089e0122e8b6eb29a7051013def9 Subject: Re: [PHP-DEV] Coercive STH - some real world tests and updated RFC From: damz@damz.org (Damien Tournoud) --089e0122e8b6eb29a7051013def9 Content-Type: text/plain; charset=UTF-8 Hi Christian, On Fri, Feb 27, 2015 at 3:38 PM, Christian Stoller wrote: > It is not a bug. FALSE as a return value of substr() is the identificator > for an error (e.g. invalid arguments), as it is stated in the > documentation: > [...] > "It is documented that way" and "it is not a bug" are two very different things. In that case, the semantics of `substr()` are just wrong. It makes a lot more sense for a sub-string function to silently allow reading before the beginning and past the end of a string. Moreover, the *conditions* under which `substr()` returns FALSE looks completely arbitrary, see http://3v4l.org/gtFjk -- in a nutshell: so it is OK to read past the beginning, it is OK to try to get more characters than the string has, but it is NOT OK to try to start reading past the end? This behavior is unpredictable, and as a consequence using `substr()` properly would require a lot of painful and unnecessary up-front checks. It traditionally did not matter, because of the fluid scalar casts. But if we want now to introduce stricter casts, we are going to have to tackle this problem, we cannot just dismiss it as a programming error. Damien --089e0122e8b6eb29a7051013def9--