Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94828 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96549 invoked from network); 4 Aug 2016 10:46:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Aug 2016 10:46:02 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ohgaki.net designates 180.42.98.130 as permitted sender) X-PHP-List-Original-Sender: yohgaki@ohgaki.net X-Host-Fingerprint: 180.42.98.130 ns1.es-i.jp Received: from [180.42.98.130] ([180.42.98.130:38304] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5A/E5-53111-8EC13A75 for ; Thu, 04 Aug 2016 06:46:02 -0400 Received: (qmail 64033 invoked by uid 89); 4 Aug 2016 10:45:57 -0000 Received: from unknown (HELO mail-qk0-f174.google.com) (yohgaki@ohgaki.net@209.85.220.174) by 0 with ESMTPA; 4 Aug 2016 10:45:57 -0000 Received: by mail-qk0-f174.google.com with SMTP id v123so94692414qkh.3 for ; Thu, 04 Aug 2016 03:45:56 -0700 (PDT) X-Gm-Message-State: AEkoouubFWZ0wahf3XmP7Q5CgftmTI/biLaT9tRIYRBeIaPElVKq29Zm8Dh1XD7KarHByBhztPGIajConTwWsg== X-Received: by 10.55.39.81 with SMTP id n78mr5528805qkn.10.1470307549685; Thu, 04 Aug 2016 03:45:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.85.242 with HTTP; Thu, 4 Aug 2016 03:45:09 -0700 (PDT) In-Reply-To: <6811e0bd-811c-bd44-2e84-6d08aa8eef9d@gmail.com> References: <6811e0bd-811c-bd44-2e84-6d08aa8eef9d@gmail.com> Date: Thu, 4 Aug 2016 19:45:09 +0900 X-Gmail-Original-Message-ID: Message-ID: To: Rowan Collins Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Re: Adding validate_var_array()/validate_input_array() to which version? From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi Rowan, On Tue, Aug 2, 2016 at 11:37 PM, Rowan Collins wrote: > On 01/08/2016 23:12, Yasuo Ohgaki wrote: >> >> Raising Exception would be prefered. >> Any comment raising exception? ExceptionFilterValidate wouldn't >> cause much BC, IMO. > > > I don't follow. Do you mean throwing an exception to the existing > filter-and-continue functions? If so, that would surely break every single > use of those functions. Existing filters currently used are not changed at all. They behave exactly as they are now. If not, it's a bug. Exceptions are raised only when validate_*() functions are used. Input validations should pass almost always. So checking return value from validation functions are not prefered. > > Or do you mean adding a new function which either silently succeeds or > throws an exception? That doesn't sound good to me - an exception shouldn't > be the expected result of something, and invalid input is an expected > condition (just an undesirable one). It's easier to add a throw statement > based on a boolean result than to catch an exception and continue with other > checks. > > I may have misunderstood your question, though. Invalid inputs that violate input validation rules should not happen almost always because input validation is _not_ the same input mistakes by normal users. e.g. typo, user send a little too long password. These mistakes should be handled as input errors/mistakes, not input validation error. Example input validation errors are, - Broken UTF-8 encoding - NUL, etc control chars in string. - Too long or too short string. e.g. Client side validation inputs - JS validated and values set by server programs like , hash value, etc. - and so on. If there are these kind of inputs, they are intentionally broken inputs. It should result in Exception and program should be _terminated_ script execution after logging attack and sending nicely formatted page that warns attackers, for instance. validate_*() functions should be used to handle above input violations that should never happen under normal condition. Did I understand your concern correctly? I hope explained well. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net