Bug #66826 [NEW]: date() stopped accepting "\0" as a valid format value

From: Date: Wed, 05 Mar 2014 14:21:57 +0000
Subject: Bug #66826 [NEW]: date() stopped accepting "\0" as a valid format value
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184532@lists.php.net to get a copy of this message
From: butkus dot justas at gmail dot com Operating system: Linux PHP version: 5.5.9 Package: Date/time related Bug Type: Bug Bug description:date() stopped accepting "\0" as a valid format value Description: ------------ This might be either string handling related, or date-specific string handling related, but starting with PHP 5.2.1 and still occurring in PHP 5.6.0alpha2, date() (as well as DateTime::format()) does not accept "\0" (NUL) as valid formatting character as valid and truncates at that point. Likely it means that at some point date() started treating $format value as null-terminated string. Before PHP 5.2.1 the NUL byte was preserved in formatting output. Reason behind using such characters: to have some clear and easily distinguishable separator which doesn't take up visual space in output. Test script: --------------- <?php date_default_timezone_set( 'UTC' ); $time = strtotime( '2014-01-31' ); $format = "\\Fm\0 j, Y"; var_dump( date( $format, $time ) ); $datetime = new DateTime( '@' . $time ); var_dump( $datetime->format( $format ) ); Expected result: ---------------- string(12) "F01 31, 2014" string(12) "F01 31, 2014" Actual result: -------------- string(3) "F01" string(3) "F01" -- Edit bug report at https://bugs.php.net/bug.php?id=66826&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66826&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66826&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66826&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=66826&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=66826&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=66826&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=66826&r=needscript Try newer version: https://bugs.php.net/fix.php?id=66826&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=66826&r=support Expected behavior: https://bugs.php.net/fix.php?id=66826&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=66826&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=66826&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=66826&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66826&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=66826&r=dst IIS Stability: https://bugs.php.net/fix.php?id=66826&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=66826&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=66826&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=66826&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=66826&r=mysqlcfg

« previous php.bugs (#184532) next »