Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95250 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36417 invoked from network); 17 Aug 2016 03:00:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Aug 2016 03:00:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; 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:34335] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B6/B2-18246-043D3B75 for ; Tue, 16 Aug 2016 23:00:19 -0400 Received: (qmail 17830 invoked by uid 89); 17 Aug 2016 03:00:13 -0000 Received: from unknown (HELO mail-qk0-f180.google.com) (yohgaki@ohgaki.net@209.85.220.180) by 0 with ESMTPA; 17 Aug 2016 03:00:13 -0000 Received: by mail-qk0-f180.google.com with SMTP id v123so89788812qkh.2 for ; Tue, 16 Aug 2016 20:00:13 -0700 (PDT) X-Gm-Message-State: AEkoouta1vAw5iYzIERzMtjnnw6bgpaE4CU4D2x3DWD9Mw3+I1sPoEGuS+NZt+XGDDZrDUvqbQcYYs5ZnWf/EA== X-Received: by 10.55.39.81 with SMTP id n78mr43524426qkn.10.1471402807649; Tue, 16 Aug 2016 20:00:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.85.242 with HTTP; Tue, 16 Aug 2016 19:59:27 -0700 (PDT) In-Reply-To: References: Date: Wed, 17 Aug 2016 11:59:27 +0900 X-Gmail-Original-Message-ID: Message-ID: To: Marco Pivetta Cc: Dan Ackroyd , PHP Internals List Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Re: [RFC][VOTE] Add validation functions to filter module From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi Marco, On Mon, Aug 15, 2016 at 12:46 PM, Marco Pivetta wrote: > Besides what reported above by Dan, my reasoning for voting "no" is that > this API can be implemented in userland, regardless if trivial or not > > There is no reason good enough for justifying yet another added endpoint > that can even be implemented with simple function composition. OK. Thank you. You prefer full userland implementation. > > In addition to that, the lack of a strongly typed data structure for the > validation DSL makes this proposed functionality very error-prone and > obnoxious to use and maintain for future additional use-case scenarios that > may come up. This is good argument. Filter module uses definition array already. The RFC adds check function for them, too. New check function does not take care semantics, it may be improved by having class for defining validation rule. If we have to add more complex, yet robust input validation definitions as array, all we have to do is adding version number, totally different array structure or object for it. Do you want me to drop filter_check_definition() proposal? It's easy to write PHP code that does the same, and write it in the manual. It's only there, because I'm expecting comments like you've made. "There is no check function for rule definition array. It's dangerous" or something like this. > Performance impact in userland implementations can be mitigated via codegen > there (similar to what Nikic's FastRoute lib): still less complicated than > relying on the core API, maintaining it in C code, and having it locked onto > the installed PHP version. This is debatable how far PHP should implement mandatory features for web applications. Some may prefer PHP to be like Python or other normal languages that does not have web application support in core at all. Having a router in core is too much to me, too. However, I prefer PHP to have basic features that is mandatory to write simple web forms. For example, 1]); // There is RFC for this. function check_user_input_error($today) { if (strtotime($today) != date('Ymd')) { $err_msg[] = 'You have entered invalid date. '. $today; return $err_msg; } } if ($_POST['submit']) { $err_msg = check_user_input_error($_POST['Today']); if (!(empty($err_msg))) { // Save CSRF protected data into some DB } else { $_POST=array(); } } // We do need shorter/simpler/consistent escape functions somehow. ?> // Display client info and date You're using Yes, today is
Enter today's date:
Simple web forms should be able to be written by PHP core feature only. IMHO. It's impossible to teach beginners how to write code for input validations. As a result, the most important security feature, input validation, is omitted in beginner courses/examples/etc. It's great for beginners to understand what's going on Web apps and what developers should do. It's useful for small web service that requires the best performance possible as well. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net