Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67917 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76960 invoked from network); 27 Jun 2013 03:05:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2013 03:05:54 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.52 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.215.52 mail-la0-f52.google.com Received: from [209.85.215.52] ([209.85.215.52:38792] helo=mail-la0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 86/F4-51393-01CABC15 for ; Wed, 26 Jun 2013 23:05:53 -0400 Received: by mail-la0-f52.google.com with SMTP id fo12so216891lab.39 for ; Wed, 26 Jun 2013 20:05:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=0CNm6nZwULqdKesYhQbY3xbi/EpirwDNtGTiDOjzJnY=; b=x6eA9Cpb+JHSE8M8X+DHMnesaH0zJHgfu51mlk45kegmW/ZT2TgVYJNABKMJaVYnFG rRkbyL3qIiUu+ZLU34ceShWOa0X76iChvQZf/aAkD9mi5OpFccy20xGTxW3eDhRS8Gyw 2HJzWQUsLRnlLseQWnUFDcYWE89IcUVK+BFIuMoibQbRU43pv/139KvF6+tJHX0TzJ+1 O8SsP2ObJGyGBV8Z3N+4A4yQ3TuCA1PZueRdfE/5T/zI4foAscBSQU/cVN7ONOYEs3y1 sRSIL7DO6mQsr9OcbhciUKyQ0j/SjKgp/+qv3TupU81Q/B/jLctuwFbbYQjs3G2W3zy9 bbGg== X-Received: by 10.112.58.135 with SMTP id r7mr3324230lbq.89.1372302350095; Wed, 26 Jun 2013 20:05:50 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.4.233 with HTTP; Wed, 26 Jun 2013 20:05:09 -0700 (PDT) In-Reply-To: References: Date: Thu, 27 Jun 2013 12:05:09 +0900 X-Google-Sender-Auth: uNo32YAEhZ_pp8kDJTBgzRZpKgc Message-ID: To: Sherif Ramadan Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=e89a8f8388cf1a1d0504e01a0adf Subject: Re: [PHP-DEV] Re: hex2bin: E_WARNING is too much for odd string? From: yohgaki@ohgaki.net (Yasuo Ohgaki) --e89a8f8388cf1a1d0504e01a0adf Content-Type: text/plain; charset=ISO-8859-1 Hi Sherif, I would like to have consistent behavior at least within a function. 2013/6/27 Sherif Ramadan > I thought you wanted to add an extra error for malformed hex, which I > would have been fine with, but removing the error entirely? The error is > useful. It informs the user that they may have buggy code since the > function is clearly documented to expect even length hex encoded strings. It is good to have additional errors for invalid inputs. It would be beneficial for many users. I've checked some conversion(decoder) functions quickly. Functions raise E_WARNING / E_NOTICE for invalid inputs unserialize() convert_uudecode() xmlreader module Functions simply return FALSE for invalid inputs base64_decode() pg_unescape_bytea() mb_decode_mimiheader() mb_decode_numericentity() mb_convert_kana() mb_convert_encoding() mb_convert_variables() Note: mbstring functions raise errors for invalid encoding, otherwise simply return FALSE. Functions do not check validity quoted_printable_decode() xml_utf8_decode() - replaces bad chars to '?' Functions have separate error message function json_decode() - returns FALSE, but can get errors via json_last_error() Decoding errors are usually a bug or some kind of attack, so I agree to add E_NOTICEs. Exception is decoders that supposed to accept external inputs. e.g. base64_decode() and mbstring functions. I think pg_unescape_bytea() should raise E_WARNING, so I'll add it later. Adding E_WARNING to it will never be BC issue. It's obvious bug. hex2bin() will not be used for handling external inputs almost always, so raising E_WARNING make sense. I've updated pull request. (Added E_WARNING for bad hex) https://github.com/php/php-src/pull/369 Everyone is OK with this? Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --e89a8f8388cf1a1d0504e01a0adf--