Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67905 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31124 invoked from network); 26 Jun 2013 19:22:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jun 2013 19:22:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.182 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.217.182 mail-lb0-f182.google.com Received: from [209.85.217.182] ([209.85.217.182:55523] helo=mail-lb0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/16-29746-36F3BC15 for ; Wed, 26 Jun 2013 15:22:12 -0400 Received: by mail-lb0-f182.google.com with SMTP id r11so1668899lbv.13 for ; Wed, 26 Jun 2013 12:22:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:x-google-sender-auth:message-id :subject:to:content-type; bh=dyltJ4g7a9FYHsi4tUctbGEipLXPDY79RCwCj1+xX5k=; b=rTx1ixqPNTaa4L38WaNSc5qox4sPSMZ2AO3JcYGELSnB3XLjhdDINPOKkcoQVt2qg9 2PZeb/x5pjanT01tS2Iu9+Rt/AV9K2oAsxR+Fu9yMP6q1A7Xg5B/rKwwlDDgs0ODVk0Q 3nzDG7JYNLVjnS30OnoxgqMA7l4yh8RR173YNvcgGAmkgBZiZYdFW0fc8H+rjMRdxjJn dZ8fi1WvtOCw2acSPESvKJSQOxRS1lc7CiiYvnMh5YPxSKet1//0ryhTXbQnT2G8tm0p cJtDqNP0L13SKU0C3sT3mukIctCLggp8jnpbiJ4Z9MNJfgaOQ0bcVv71SEUy/Mb/Qijl RXsQ== X-Received: by 10.112.16.163 with SMTP id h3mr2686091lbd.85.1372274528287; Wed, 26 Jun 2013 12:22:08 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.4.233 with HTTP; Wed, 26 Jun 2013 12:21:28 -0700 (PDT) Date: Thu, 27 Jun 2013 04:21:28 +0900 X-Google-Sender-Auth: Tym-j2QxnehN6Ki2isZL_5BaGhA Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c3b4aecb054004e0138fea Subject: hex2bin: E_WARNING is too much for odd string? From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11c3b4aecb054004e0138fea Content-Type: text/plain; charset=ISO-8859-1 Hi all, hex2bin raises E_WARNING for odd length hex strings from PHP 5.4.1. http://jp2.php.net/manual/en/function.hex2bin.php However, just returning FALSE is easier for programmers. Current behavior requires additional length check for bad hex to prevent E_WARNING. $str = 'abZ'; if (strlen($str)%2) { // BAD hex - invalid length } else if (hex2bin($str) { // BAD hex - invalid char } Instead, it would better that hex2bin() just returns FALSE for invalid hex, IMHO. $str = 'abZ'; if (strlen($str)%2) { // BAD hex - invalid length or char } I can understand current behavior as BC. However, it would better cleanup bad spec sooner or later. PHP 5.4: Raise E_ERROR and return FALSE for invalid length. PHP 5.5: Just return FALSE. or PHP 5.4: Keep current behavior PHP 5.4: Riase E_ERROR and return FALSE for invalid length. PHP 5.5: Remove E_ERROR. Any ideas? -- Yasuo Ohgaki yohgaki@ohgaki.net --001a11c3b4aecb054004e0138fea--