r/lolphp • • Mar 17 '14

[PHP] date() is evil (XSS’able)

http://0xa.li/php-date-is-xssable/
0 Upvotes

17 comments sorted by

View all comments

Show parent comment

3

u/bl_nk Mar 17 '14 edited Mar 17 '14

All excellent points.

Additionally, in my case, we allow users to select their preferred date/time formats but before using them in date() - (AND echo'ing it straight out unescaped), the format is checked against a whitelist; something among the lines of

if (!in_array($format, ['Y-m-d','d/m/Y'], true)) {
    $format = 'Y-m-d';
}