Closed (won't fix)
Project:
Drupal core
Version:
7.x-dev
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
23 May 2009 at 22:43 UTC
Updated:
23 Aug 2009 at 22:28 UTC
In PHP 5.2, we now have filter_var() and related functions that did not exist previously.
These functions _may_ be able to replace the following Drupal 6 functions.
filter_xss*()
check_plain()
check_url()
check_markup()
valid_email_address()
valid_url()
See http://us.php.net/manual/en/book.filter.php.
We need new functions and tests to confirm that we can use the PHP standard functions, which will improve DX by removing Drupal-specific code that is no longer needed.
Comments
Comment #1
sunAdding to the mixture of function names:
- drupal_validate_utf8()
- drupal_valid_http_host()
Similar, so potentially also:
- drupal_query_string_encode()
- _fix_gpc_magic()
- _fix_gpc_magic_files()
- drupal_urlencode()
- drupal_valid_token()
Note that
- check_file()
does not really belong into that list, but shares the same prefix.
Comment #2
sunAlso note that we're already using filter_var() in http://api.drupal.org/api/function/valid_email_address/7
Comment #3
agentrickardWeird.
So my first question is: Do we want Drupal-specific wrapper functions in future?
Comment #4
sunI'm inclined to say "yes", because
- if all validation and sanitation functions use a common prefix and function name pattern = better DX
- if we rely on PHP's own filter functions for some, but not for others = bad DX
- PHP's own filter functions require developers to know and use cryptic flags and options, so there is no guaranteed standard = bad for security.
Comment #5
catchSubscribe. check_plain() and drupal_validate_utf8() take up a lot of time on some page requests (more than 10% of the entire request sometimes). Good to explore other options.
Comment #6
damien tournoud commentedLet's study this quickly and close this issue:
About others pointed out by sun:
All in one, I see no patterns there. Closing this issue, let's discuss some potential refactoring separately.
Comment #7
agentrickardNice to have this all in one place. sun and I were having a separate IRC conversation and were not aware.
Comment #8
sun#471264: Consistently name validation/sanitation functions
Comment #9
joshmillerCleaning up DrupalWTF list... Since this is a duplicate, removing tag...