results of the PHP6 wishlists

php.internals

Ron Korving

20 years ago
I was wondering; we've seen quite a few PHP6 wishlists passing by here. Is there (and if not: should there be) a centralized spot where changes and new features are logged, perhaps with a status saying whether somebody (and who) is working on this, or if it's still being considered, or if it has been rejected, etc... Ron

Lukas Smith

20 years ago
Ron Korving wrote:
> I was wondering; we've seen quite a few PHP6 wishlists passing by here. Is > there (and if not: should there be) a centralized spot where changes and new > features are logged, perhaps with a status saying whether somebody (and who) > is working on this, or if it's still being considered, or if it has been > rejected, etc...
I have created such a list with the help of a bunch of others. Its by no means official, but fairly complete (yet its likely that most of the points there will never make it): http://oss.backendmedia.com/PhP60 regards, Lukas

Cesare D'Amico

20 years ago
Alle 09:36, lunedì 14 novembre 2005, Lukas Smith ha scritto:
> http://oss.backendmedia.com/PhP60
Bundle a default application server, ie a default way to hold objects/variables in memory (on ANY operating system) between two HTTP requests? Anyone interested? Ciao ce
-- Cesare D'Amico php developer - linux sysadmin c . damico @ wyrd-software . com Key on pgp.mit.edu, ID 92802693 ICQ 66605157 - Skype cesaredamico - Mobile +39 320 0635 028 "If you always do what you've always done, you'll always get what you've always got", and then wonder why nothing's changed

Cesare D'Amico

20 years ago
Alle 12:25, lunedì 14 novembre 2005, Cesare D'Amico ha scritto:
> a default way to hold objects/variables in memory (on ANY operating > system) between two HTTP requests
Hey, I didn't mean sessions :) I meant something like creating a complex object and holding it in memory with its classes hierarchy, so I don't need to reload it all at every single request. Ciao
-- Cesare D'Amico php developer - linux sysadmin c . damico @ wyrd-software . com Key on pgp.mit.edu, ID 92802693 ICQ 66605157 - Skype cesaredamico - Mobile +39 320 0635 028 "If you always do what you've always done, you'll always get what you've always got", and then wonder why nothing's changed

Lukas Smith

20 years ago
Cesare D'Amico wrote:
> Alle 12:25, lunedì 14 novembre 2005, Cesare D'Amico ha scritto: > >>a default way to hold objects/variables in memory (on ANY operating >>system) between two HTTP requests > > > Hey, I didn't mean sessions :) > > I meant something like creating a complex object and holding it in > memory with its classes hierarchy, so I don't need to reload it all at > every single request.
You mean something like SRM: http://www.vl-srm.net/ Though a bit more finished :-) regards, Lukas

Cesare D'Amico

20 years ago
Alle 14:58, lunedì 14 novembre 2005, Lukas Smith ha scritto:
> You mean something like SRM: > http://www.vl-srm.net/ > > Though a bit more finished :-)
Exactly! I didn't mention it, but that's what I was thinking about. And it would be nice if it was for PHP5 too :)
-- Cesare D'Amico php developer - linux sysadmin c . damico @ wyrd-software . com Key on pgp.mit.edu, ID 92802693 ICQ 66605157 - Skype cesaredamico - Mobile +39 320 0635 028 "If you always do what you've always done, you'll always get what you've always got", and then wonder why nothing's changed

Jani Taskinen

20 years ago
On Mon, 14 Nov 2005, Cesare D'Amico wrote:
> > Alle 14:58, lunedì 14 novembre 2005, Lukas Smith ha scritto: >> You mean something like SRM: >> http://www.vl-srm.net/ >> >> Though a bit more finished :-) > > Exactly! I didn't mention it, but that's what I was thinking about.
IMO, no. (bundling SRM or any other such thing)
> And it would be nice if it was for PHP5 too :)
It think what we have in CVS works with PHP 5. --Jani

Cesare D'Amico

20 years ago
Alle 21:10, lunedì 14 novembre 2005, Jani Taskinen ha scritto:
> > Exactly! I didn't mention it, but that's what I was thinking about. > >      IMO, no. (bundling SRM or any other such thing)
I don't want to bother, but why not? I'm accepting a simple RTFA (read the friendly archives :) if that was discussed yet (but keep in mind that this is a major number change). Thanks, ciao cesare
-- Cesare D'Amico php developer - linux sysadmin c . damico @ wyrd-software . com Key on pgp.mit.edu, ID 92802693 ICQ 66605157 - Skype cesaredamico - Mobile +39 320 0635 028 "If you always do what you've always done, you'll always get what you've always got", and then wonder why nothing's changed

Marcus Börger

20 years ago
Hello Cesare, Monday, November 14, 2005, 9:45:38 PM, you wrote:
> Alle 21:10, lunedì 14 novembre 2005, Jani Taskinen ha scritto: >> > Exactly! I didn't mention it, but that's what I was thinking about. >> >>      IMO, no. (bundling SRM or any other such thing)
> I don't want to bother, but why not? I'm accepting a simple RTFA (read > the friendly archives :) if that was discussed yet (but keep in mind > that this is a major number change).
Simply because it is not the PHP way. And of course until now Derick did not seem to push to bring it there. If anyone else writes an application server and publishes it to pecl and using an application server becomes the normal way in PHP it would most definitively added. However without an application server you can still use a database or a apc's apc_store/fetch. However it doesn't handle objects right now so you'd need to serialize them. Another thing you may probably want to notice is that storing an object is not everything. You would need to serialize access to it or copy it or talk to it through some communication system. Java choses the latter with on the one hand the farmost slowest since it also includes locking but on the other hand the solution that scales most (once you've brought in the power to enable that locking and communication). Also which ever solution you choose, your sysem will get much more complex. Thus PHP takes the KISS approach - keep it simple safe. Best regards, Marcus

Cesare D'Amico

20 years ago
Alle 22:05, lunedì 14 novembre 2005, Marcus Boerger ha scritto:
> Simply because it is not the PHP way.
[...]
> Thus PHP takes the KISS approach - keep it simple safe.
Fair enough, that's understandable :) Thanks, Cesare
-- Cesare D'Amico php developer - linux sysadmin c . damico @ wyrd-software . com Key on pgp.mit.edu, ID 92802693 ICQ 66605157 - Skype cesaredamico - Mobile +39 320 0635 028 "If you always do what you've always done, you'll always get what you've always got", and then wonder why nothing's changed

Rasmus Lerdorf

20 years ago
Cesare D'Amico wrote:
> Alle 21:10, lunedì 14 novembre 2005, Jani Taskinen ha scritto: >>> Exactly! I didn't mention it, but that's what I was thinking about. >> IMO, no. (bundling SRM or any other such thing) > > I don't want to bother, but why not? I'm accepting a simple RTFA (read > the friendly archives :) if that was discussed yet (but keep in mind > that this is a major number change).
Until there is an implementation out there that is in common use, the question of whether to bundle it or not is rather premature. -Rasmus

Cesare D'Amico

20 years ago
Alle 22:28, lunedì 14 novembre 2005, Rasmus Lerdorf ha scritto:
> Until there is an implementation out there that is in common use, the > question of whether to bundle it or not is rather premature.
Until there is a standard (planned or de-facto) and widely installed implementation (ie, one that is bundled with php ;) I doubt that any will be in common use, at any time. Anyway, Marcus' response was crystal clear, so I have nothing more to argue :) Thanks, Cesare
-- Cesare D'Amico php developer - linux sysadmin c . damico @ wyrd-software . com Key on pgp.mit.edu, ID 92802693 ICQ 66605157 - Skype cesaredamico - Mobile +39 320 0635 028 "If you always do what you've always done, you'll always get what you've always got", and then wonder why nothing's changed

Roman Ivanov

20 years ago
wishlist> input filter extension (including some element of user wishlist> control) Will it be used _instead_ of $_POST and $_GET? Honestly, I'm not so sure it's a good idea to implement it like PECL extension does. Filtering individual variables is, in my opinion, a wrong way to treat user input. The way I do it on my sites: 1) Call dispatcher parses request variables to find out what to do. This is done before request filtering. 2) System loads the filter that correspond to the target action. 3) If _any_ of the request variables are invalid, than system does not perform the action. Instead, it outputs message, stating which field was filled incorrectly. 4) If all variables are correct, than system makes an array of "clean" variable (i.e. only ones that were checked) and passes it to some function. Simplified example: $filter = array( 'name'=>'/^[\w\d]+$/', 'zip'=>'/^\d{5}$/', 'phone'=>'/^\d{7,16}$/', ); try { $input = filterInput($filter); } catch (InvalidField $e) { echo $e; die(); } Besides, is it really necessary to make input filtering a part of the language? It's a very high-level feature, and implementation may vary according to the needs of the developer. Plus, it's perfectly doable in pure PHP. In fact, I would go as far as removing session handling functions from the "core" language too. Such things would better fit a framework or CMS. My two cents, anyway.

Antony Dovgal

20 years ago
On 14.11.2005 12:55, Roman Ivanov wrote:
> wishlist> input filter extension (including some element of user > wishlist> control) > > Will it be used _instead_ of $_POST and $_GET?
An extension instead of the arrays? You must be missing something...
> Honestly, I'm not so sure > it's a good idea to implement it like PECL extension does. Filtering > individual variables is, in my opinion, a wrong way to treat user input.
You may filter data recursively, so filtering, for example, _POST or _GET would work fine.
> Besides, is it really necessary to make input filtering a part of the > language?
An extension is not a part of the language, you may or may not compile it, while the language is still there.
> It's a very high-level feature, and implementation may vary > according to the needs of the developer. Plus, it's perfectly doable in > pure PHP.
Yeah, that's why you can use your own callback for filtering.
> In fact, I would go as far as removing session handling > functions from the "core" language too.
You're late. Four or three years ago I'd agree with you, but it's too late for that.
-- Wbr, Antony Dovgal

Roman Ivanov

20 years ago
Antony Dovgal wrote:
> On 14.11.2005 12:55, Roman Ivanov wrote: > >> wishlist> input filter extension (including some element of user >> wishlist> control) >> >> Will it be used _instead_ of $_POST and $_GET? > > > An extension instead of the arrays? > You must be missing something...
I do not think so. If the only way to get 'post' and 'get' variables will be trough input_get(), then filter extension will effectively and functionally replace those arrays. Is it not righ?
>> Honestly, I'm not so sure it's a good idea to implement it like PECL >> extension does. Filtering individual variables is, in my opinion, a >> wrong way to treat user input. > > > You may filter data recursively, so filtering, for example, _POST or > _GET would work fine.
Recursion does not solve the problem I'm trying to highlight. //Way #1: $filter = array( 'name' => '/^[\w\d]+$/', 'email' => RE_EMAIL, 'wage'=> new IntFilter(5, 500), 'phone'=>'/^\d{7,16}$/', ); try { $input = filterInput($filter); } catch (InvalidField $e) { user_error($e, E_USER_ERROR); } /*--------------------------------------------*/ //Way #2: $name = input_get(INPUT_GET, 'name', FL_REGEXP, '/^[\w\d]+$/'); if ($name === NULL) { user_error("Invalid 'name' field", E_USER_ERROR); } $email= input_get(INPUT_GET, 'email', FL_EMAIL); if ($name === NULL) { user_error("Invalid 'email' field", E_USER_ERROR); } $wage= input_get(INPUT_GET, 'wage', FL_INT, array('min_range' => 5, 'max_range' => 500)); if ($wage === NULL) { user_error("Invalid 'wage' field", E_USER_ERROR); } $phone= input_get(INPUT_GET, 'phone', FL_REGEXP, '^\d{7,16}$'); if ($phone === NULL) { user_error("Invalid 'phone' field", E_USER_ERROR); }
>> Besides, is it really necessary to make input filtering a part of the >> language? > > > An extension is not a part of the language, you may or may not compile > it, while the language is still there.
"Part of the standard API, which is included with PHP and compiles by default", if you will.
>> It's a very high-level feature, and implementation may vary according >> to the needs of the developer. Plus, it's perfectly doable in pure PHP. > > > Yeah, that's why you can use your own callback for filtering.
Callback just plugs your function in some pre-defined structure.

Antony Dovgal

20 years ago
On 15.11.2005 05:38, Roman Ivanov wrote:
> Antony Dovgal wrote: >> On 14.11.2005 12:55, Roman Ivanov wrote: >> >>> wishlist> input filter extension (including some element of user >>> wishlist> control) >>> >>> Will it be used _instead_ of $_POST and $_GET? >> >> >> An extension instead of the arrays? >> You must be missing something... > > I do not think so. If the only way to get 'post' and 'get' variables > will be trough input_get(), then filter extension will effectively and > functionally replace those arrays. Is it not righ?
Obviously, no, this won't be the only way to get the data.
>>> Honestly, I'm not so sure it's a good idea to implement it like PECL >>> extension does. Filtering individual variables is, in my opinion, a >>> wrong way to treat user input. >> >> >> You may filter data recursively, so filtering, for example, _POST or >> _GET would work fine. > > Recursion does not solve the problem I'm trying to highlight. > > //Way #1:
<skip>
> //Way #2:
<skip> Didn't get the problem, sorry. Could you try to explain it once more?
> "Part of the standard API, which is included with PHP and compiles by > default", if you will.
So, basically you're objecting against enabling it by default? Why? I really do not see a reason to not include it by default, if it helps to write more secure code. (remember that "enabled by default" means you can disable it in a moment).
>> Yeah, that's why you can use your own callback for filtering. > Callback just plugs your function in some pre-defined structure.
Right. Feel free to write your own PHP class/library for filtering, if you think that this predefined structure doesn't fit your needs.
-- Wbr, Antony Dovgal

Roman Ivanov

20 years ago
Antony Dovgal wrote:
> Obviously, no, this won't be the only way to get the data.
That's good.
>>>> Honestly, I'm not so sure it's a good idea to implement it like PECL >>>> extension does. Filtering individual variables is, in my opinion, a >>>> wrong way to treat user input. >>> >>> You may filter data recursively, so filtering, for example, _POST or >>> _GET would work fine. >> >> Recursion does not solve the problem I'm trying to highlight. >> > Didn't get the problem, sorry. > Could you try to explain it once more?
This particular extension treats each input variable individually, which is not desirable in majority of scripts I worked with. Such approach adds unnecessary complexity to the script, and requires to handle each invalid variable separately as well. But the real problem is that there are many ways of filtering input, and I do not think any of them fits all the situations.
>> "Part of the standard API, which is included with PHP and compiles by >> default", if you will. > > > So, basically you're objecting against enabling it by default? > Why? I really do not see a reason to not include it by default, if it > helps to write more secure code. > (remember that "enabled by default" means you can disable it in a
moment). Well, I think that everything in core distribution is a suggested standard. But a language should not, in my opinion, suggest any particular structure for the program, unless it's absolutely necessary. It's not a major issue, but still...

Antony Dovgal

20 years ago
On 15.11.2005 15:06, Roman Ivanov wrote:
> This particular extension treats each input variable individually, which > is not desirable in majority of scripts I worked with. Such approach > adds unnecessary complexity to the script, and requires to handle each > invalid variable separately as well. But the real problem is that there > are many ways of filtering input, and I do not think any of them fits > all the situations.
Ahha. So what exactly do you propose? For example, I have 3 different variables: an email, an integer and a string. How do you think I should filter them ?
> >> "Part of the standard API, which is included with PHP and compiles by > >> default", if you will. > > > > > > So, basically you're objecting against enabling it by default? > > Why? I really do not see a reason to not include it by default, if it > > helps to write more secure code. > > (remember that "enabled by default" means you can disable it in a > moment). > > Well, I think that everything in core distribution is a suggested > standard. But a language should not, in my opinion, suggest any > particular structure for the program, unless it's absolutely necessary. > It's not a major issue, but still...
Sorry, I refuse to understand that. The language HAS to recommend a way to do something and to allow user to choose any other way if the recommended one doesn't fit his/her needs. If there is no a recommended way to do, for example, input filtering, users would re-invent the wheel every time, which results in square wheels and engines with security issues discovered every day. That's the whole point: to provide a fast and comfortable way to filter data, so the users won't have to do it themselves. Feel free to offer an improvements, if you have something to offer, but saying that a standard method of doing something *imposes* a particular structure is just a nonsense.
-- Wbr, Antony Dovgal

Roman Ivanov

20 years ago
Antony Dovgal wrote:
> On 15.11.2005 15:06, Roman Ivanov wrote: > >> This particular extension treats each input variable individually, >> which is not desirable in majority of scripts I worked with. Such >> approach adds unnecessary complexity to the script, and requires to >> handle each invalid variable separately as well. But the real problem >> is that there are many ways of filtering input, and I do not think any >> of them fits all the situations. > > > Ahha. > So what exactly do you propose? > For example, I have 3 different variables: an email, an integer and a > string. > How do you think I should filter them ?
Sorry, do not have time to simplify. This is how I do it: function filterRequest($prototype, $action){ loadPrototype($prototype); $vars = get_class_vars($prototype); if ($vars['vigilant'] == FALSE) { return $_REQUEST; } $filter = getFilter($prototype, $action); if ($filter == NULL) { return NULL; } if ($filter == TRUE) { return $_REQUEST; } $cleanedVars = array(); foreach ($filter as $fieldName => $rule) { if ($rule === TRUE) { $cleanedVars[$fieldName] = @$_REQUEST[$fieldName]; continue; }// else { $positiveMatch = TRUE; if (preg_match('/n\w*$/', $rule)) { //check whether regExp has n modifier $positiveMatch = FALSE; $rule = preg_replace('/n(\w*)$/', '$1', $rule); //remove modifier so PHP won't complain } if (preg_match($rule, @$_REQUEST[$fieldName]) && $positiveMatch) { $cleanedVars[$fieldName] = @$_REQUEST[$fieldName]; } else { user_error("Request filtered out because of '$fieldName' field", E_USER_WARNING); return NULL; } //} } return $cleanedVars; }
>> >> "Part of the standard API, which is included with PHP and compiles by >> >> default", if you will. >> > >> > >> > So, basically you're objecting against enabling it by default? >> > Why? I really do not see a reason to not include it by default, if it >> > helps to write more secure code. >> > (remember that "enabled by default" means you can disable it in a >> moment). >> >> Well, I think that everything in core distribution is a suggested >> standard. But a language should not, in my opinion, suggest any >> particular structure for the program, unless it's absolutely >> necessary. It's not a major issue, but still... > > > Sorry, I refuse to understand that. > The language HAS to recommend a way to do something and to allow user to > choose any other way if the recommended one doesn't fit his/her needs.
Perl: There is more than one way to do it. Java: There is more than one way to do it, as long as you're doing it our way. C: Use assembly.

Michael Wallner

20 years ago
Hi Roman Ivanov, you wrote:
> Sorry, do not have time to simplify. This is how I do it: > > function filterRequest($prototype, $action){ > loadPrototype($prototype); > $vars = get_class_vars($prototype); > if ($vars['vigilant'] == FALSE) { > return $_REQUEST; > } > > $filter = getFilter($prototype, $action); > if ($filter == NULL) { > return NULL; > } > if ($filter == TRUE) { > return $_REQUEST; > }
If this is the code you're using, it's useless. Anything after those two statements is "unreachable code", i.e. you do no filtering at all. Regards,
-- Michael - <mike(@)php.net> http://dev.iworks.at/ext-http/http-functions.html.gz

Matt Asher

20 years ago
> On 15.11.2005 15:06, Roman Ivanov wrote: > >> This particular extension treats each input variable individually, >> which is not desirable in majority of scripts I worked with. Such >> approach adds unnecessary complexity to the script, and requires to >> handle each invalid variable separately as well.
Just to weigh in here with a strong preference to *not* implement any filtering-by-default scheme on all input. As mentioned before every input is different: email, html, binary data, etc. It seems pretty clear that dealing with this data is the job of the framework, the cms, or if you want an extension. For example, our in-house framework has a library of "validators" (return true or false) and "normalizers" (input can be changed, not just accepted or rejected). No user data makes it into a global without being filtered in this way, and these filters can set global "flags" the programmer can use: $email = valid_email($_POST['email']); $message = normailze_text($_POST['message']); if(count($REPORTS['bad_data'])) { // Tell user about bad input } if(count($REPORTS['changed_data'])) { // Do we need to let user know we stripped out tags? // Do we need to notify the webmaster about what got changed? } That's just a small part of the system, and the point here isn't that our way of filtering is best and certainly not the only way, but it does represent a deliberate choice of how to deal with user data that has lots of nifty features and works with our system as a whole. Any filtering system enabled by default would break our system when we distribute it to other people unless we could disable that system at run-time, and it would probably end up dodging or deciding business-logic decisions that should be dealt with by the script.
-- Asher -----Original Message----- From: Antony Dovgal [mailto:antony@zend.com] Sent: Tuesday, November 15, 2005 5:33 AM To: Roman Ivanov Cc: internals@lists.php.net Subject: Re: [PHP-DEV] Re: results of the PHP6 wishlists On 15.11.2005 15:06, Roman Ivanov wrote: > This particular extension treats each input variable individually, which > is not desirable in majority of scripts I worked with. Such approach > adds unnecessary complexity to the script, and requires to handle each > invalid variable separately as well. But the real problem is that there > are many ways of filtering input, and I do not think any of them fits > all the situations. Ahha. So what exactly do you propose? For example, I have 3 different variables: an email, an integer and a string. How do you think I should filter them ? > >> "Part of the standard API, which is included with PHP and compiles by > >> default", if you will. > > > > > > So, basically you're objecting against enabling it by default? > > Why? I really do not see a reason to not include it by default, if it > > helps to write more secure code. > > (remember that "enabled by default" means you can disable it in a > moment). > > Well, I think that everything in core distribution is a suggested > standard. But a language should not, in my opinion, suggest any > particular structure for the program, unless it's absolutely necessary. > It's not a major issue, but still... Sorry, I refuse to understand that. The language HAS to recommend a way to do something and to allow user to choose any other way if the recommended one doesn't fit his/her needs. If there is no a recommended way to do, for example, input filtering, users would re-invent the wheel every time, which results in square wheels and engines with security issues discovered every day. That's the whole point: to provide a fast and comfortable way to filter data, so the users won't have to do it themselves. Feel free to offer an improvements, if you have something to offer, but saying that a standard method of doing something *imposes* a particular structure is just a nonsense. -- Wbr, Antony Dovgal -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Jani Taskinen

20 years ago
It's up to you to enable/disable it and set the default filtering mode. But it will be on by default. --Jani On Tue, 15 Nov 2005, Matt Asher wrote:
> >> On 15.11.2005 15:06, Roman Ivanov wrote: >> >>> This particular extension treats each input variable individually, >>> which is not desirable in majority of scripts I worked with. Such >>> approach adds unnecessary complexity to the script, and requires to >>> handle each invalid variable separately as well. > > Just to weigh in here with a strong preference to *not* implement any > filtering-by-default scheme on all input. As mentioned before every input is > different: email, html, binary data, etc. It seems pretty clear that dealing > with this data is the job of the framework, the cms, or if you want an > extension. > > For example, our in-house framework has a library of "validators" (return > true or false) and "normalizers" (input can be changed, not just accepted or > rejected). No user data makes it into a global without being filtered in > this way, and these filters can set global "flags" the programmer can use: > > $email = valid_email($_POST['email']); > $message = normailze_text($_POST['message']); > > if(count($REPORTS['bad_data'])) { > // Tell user about bad input > } > > if(count($REPORTS['changed_data'])) { > // Do we need to let user know we stripped out tags? > // Do we need to notify the webmaster about what got changed? > } > > > That's just a small part of the system, and the point here isn't that our > way of filtering is best and certainly not the only way, but it does > represent a deliberate choice of how to deal with user data that has lots of > nifty features and works with our system as a whole. Any filtering system > enabled by default would break our system when we distribute it to other > people unless we could disable that system at run-time, and it would > probably end up dodging or deciding business-logic decisions that should be > dealt with by the script. > > -- > Asher > > -----Original Message----- > From: Antony Dovgal [mailto:antony@zend.com] > Sent: Tuesday, November 15, 2005 5:33 AM > To: Roman Ivanov > Cc: internals@lists.php.net > Subject: Re: [PHP-DEV] Re: results of the PHP6 wishlists > > On 15.11.2005 15:06, Roman Ivanov wrote: >> This particular extension treats each input variable individually, which >> is not desirable in majority of scripts I worked with. Such approach >> adds unnecessary complexity to the script, and requires to handle each >> invalid variable separately as well. But the real problem is that there >> are many ways of filtering input, and I do not think any of them fits >> all the situations. > > Ahha. > So what exactly do you propose? > For example, I have 3 different variables: an email, an integer and a > string. > How do you think I should filter them ? > >> >> "Part of the standard API, which is included with PHP and compiles by >> >> default", if you will. >> > >> > >> > So, basically you're objecting against enabling it by default? >> > Why? I really do not see a reason to not include it by default, if it >> > helps to write more secure code. >> > (remember that "enabled by default" means you can disable it in a >> moment). >> >> Well, I think that everything in core distribution is a suggested >> standard. But a language should not, in my opinion, suggest any >> particular structure for the program, unless it's absolutely necessary. >> It's not a major issue, but still... > > Sorry, I refuse to understand that. > The language HAS to recommend a way to do something and to allow user to > choose any other way if the recommended one doesn't fit his/her needs. > If there is no a recommended way to do, for example, input filtering, users > would re-invent the wheel every time, which results in square wheels and > engines with security issues discovered every day. > That's the whole point: to provide a fast and comfortable way to filter > data, so the users won't have to do it themselves. > > Feel free to offer an improvements, if you have something to offer, but > saying that a standard method of doing something *imposes* a particular > structure is just a nonsense. > >
-- Give me your money at @ <http://pecl.php.net/wishlist.php/sniper> Donating money may make me happier and friendlier for a limited period! Death to all 4 letter abbreviations starting with P!

Roman Ivanov

20 years ago
wishlist> input filter extension (including some element of user control) Will it be used _instead_ of $_POST and $_GET? Honestly, I'm not so sure it's a good idea to implement it like PECL extension does. Filtering individual variables is, in my opinion, a wrong way to treat user input. The way I do it on my sites: 1) Call dispatcher parses request variables to find out what to do. This is done before request filtering. 2) System loads the filter that correspond to the target action. 3) If _any_ of the request variables are invalid, than system does not perform the action. Instead, it outputs message, stating which field was filled incorrectly. 4) If all variables are correct, than system makes an array of "clean" variable (i.e. only ones that were checked) and passes it to some function. Simplified example: $filter = array( 'name'=>'/^[\w\d]+$/', 'zip'=>'/^\d{5}$/', 'phone'=>'/^\d{7,16}$/', ); try { $input = filterInput($filter); } catch (InvalidField $e) { echo $e; die(); } Besides, is it really necessary to make input filtering a part of the language? It's a very high-level feature, and implementation may vary according to the needs of the developer. Plus, it's perfectly doable in pure PHP. In fact, I would go as far as removing session handling functions from the "core" language too. Such things would better fit a framework or CMS. My two cents, anyway.