Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25766 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39918 invoked by uid 1010); 19 Sep 2006 21:26:26 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 39903 invoked from network); 19 Sep 2006 21:26:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Sep 2006 21:26:26 -0000 Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain php.net from 82.94.239.5 cause and error) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.94.239.5 jdi.jdi-ict.nl Linux 2.5 (sometimes 2.4) (4) Received: from [82.94.239.5] ([82.94.239.5:58953] helo=jdi.jdi-ict.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 42/8C-54096-18060154 for ; Tue, 19 Sep 2006 17:26:26 -0400 Received: from localhost (localhost [127.0.0.1]) by jdi.jdi-ict.nl (8.13.7/8.12.11) with ESMTP id k8JLQMDi019318; Tue, 19 Sep 2006 23:26:22 +0200 Date: Tue, 19 Sep 2006 23:26:13 +0200 (CEST) X-X-Sender: derick@localhost To: Pierre cc: internals@lists.php.net, rasmus@php.net, ilia@prohost.org In-Reply-To: <20060916125431.42e9a5dd@pierre-u64> Message-ID: References: <20060916125431.42e9a5dd@pierre-u64> X-Face: "L'&?Ah3MYF@FB4hU'XhNhLB]222(Lbr2Y@F:GE[OO;"F5p>qtFBl|yVVA&D{A(g3[C}mG:199P+5C'v.M/u@Z\![0b:Mv.[l6[uWl' MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] ext/filter, Final API proposal From: derick@php.net (Derick Rethans) On Sat, 16 Sep 2006, Pierre wrote: > Hello, > > Given the recent discussion about the filter API in the pecl-dev list > (http://news.php.net/php.pecl.dev/4123), I summarize again what I > proposed a while back. It is very important to agree on an API now or > we will have to remove filter from 5.2.0. > > This proposal does not reflect what we have now in CVS. > > The major changes are: > - drop filter_data, input_get will use INPUT_DATA just like > input_get_args > > - input_get accepts takes no option or flag by default, only the filter > type. If you need options or flags, you pass them and the filter type > as array. Consistent and flexible. I think that is a bad idea, and it's also something I disliked in the _get_args() implementation as we'd basically be overloading the parameter then. I would not want that for input_get(), and I think we should also come up with something else for the definition in input_get_args() there as well. > Please reply as soon as possible (yes, many of us are on their way > home :). Also I ask you to focus on the API itself, not on a missing > filter type, option or flag. Such things can be added anytime after > 5.2.0. > > Proposal: > ********** > > I. Availalbe functions: > ------------------- > > * input_get > Gets variable from outside PHP or from a userland variable and > optionally filters it using one filter and its options or flags. It > accepts only scalar by default, array can be returned using > ALLOW_ARRAY. > > * input_get_args > Gets multiple variables from outside PHP or from a userland variable > and optionally filters them using different filters and options/flags. > It accepts only scalar by default, array can be returned using > ALLOW_ARRAY. > > * input_has_variable > Checks if variable of specified type exists. > > * input_name_to_filter > Returns the filter ID belonging to a named filter > > * input_ filters_ list > Returns a list of all supported filters Without the spaces I hope :) > > II input_get usages > > II.1 without options or flags > > ?mystring=bold > input_get(INPUT_POST, 'mystring', FILTER_SANITIZE_SPECIAL_CHARS); > > ?myint=493 > input_get(INPUT_GET, 'myint', FILTER_VALIDATE_INT); > > Using a user variable: $userint = 493; > input_get(INPUT_DATA, $userint, FILTER_VALIDATE_INT); > > > II.2 with options or flags > > /*mystring=bold*/ > input_get(INPUT_GET, 'mystring', array( > 'filter' =>FILTER_SANITIZE_STRING, > 'flags' => FILTER_FLAG_ENCODE_HIGH > |FILTER_FLAG_ENCODE_LOW > ) > ); I think we should just stick to the old syntax here: input_get(INPUT_GET, 'mystring', FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_HIGH|FILTER_FLAG_ENCODE_LOW ); [snip two examples] In that case INPUT_DATA becomes ugly so I prefer a different function for filtering already existing data in variables (as you're not getting any input as "input_get" refers to). [snip III. input_get_args (require array as arguments)] regards, Derick