summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorDerick Rethans <github@derickrethans.nl>2013-11-27 21:59:46 +0000
committerDerick Rethans <github@derickrethans.nl>2013-11-27 21:59:46 +0000
commit23ab2575e1be062c2d5e3f80d3ff40cabe14fa2c (patch)
treefdbb26f3990a71ee2f8ea8e8103ae3d6aaf785c6 /ext
parent504c60dc4451b8ede8814530dbfec0ef485f0ca6 (diff)
downloadphp-git-23ab2575e1be062c2d5e3f80d3ff40cabe14fa2c.tar.gz
Fixed bug #53879 (DateTime::createFromFormat() fails to parse cookie expiration date)
Diffstat (limited to 'ext')
-rw-r--r--ext/date/php_date.c12
-rw-r--r--ext/date/tests/DateTime_format_basic2.phpt2
-rw-r--r--ext/date/tests/DateTime_verify.phpt4
-rw-r--r--ext/date/tests/bug52063.phpt4
-rw-r--r--ext/date/tests/bug53879.phpt14
-rw-r--r--ext/date/tests/date_constants.phpt4
-rw-r--r--ext/date/tests/gmdate_variation13.phpt4
-rw-r--r--ext/date/tests/test-parse-from-format.phpt4
8 files changed, 35 insertions, 13 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 7e4de09c1e..b7da07c7bd 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -752,6 +752,14 @@ PHP_RSHUTDOWN_FUNCTION(date)
#define DATE_FORMAT_ISO8601 "Y-m-d\\TH:i:sO"
+/*
+ * This comes from various sources that like to contradict. I'm going with the
+ * format here because of:
+ * http://msdn.microsoft.com/en-us/library/windows/desktop/aa384321%28v=vs.85%29.aspx
+ * and http://curl.haxx.se/rfc/cookie_spec.html
+ */
+#define DATE_FORMAT_COOKIE "l, d-M-Y H:i:s T"
+
#define DATE_TZ_ERRMSG \
"It is not safe to rely on the system's timezone settings. You are " \
"*required* to use the date.timezone setting or the " \
@@ -783,7 +791,7 @@ PHP_MINIT_FUNCTION(date)
* with the variations that the only legal time zone is GMT
* and the separators between the elements of the date must be dashes."
*/
- REGISTER_STRING_CONSTANT("DATE_COOKIE", DATE_FORMAT_RFC850, CONST_CS | CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("DATE_COOKIE", DATE_FORMAT_COOKIE, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("DATE_ISO8601", DATE_FORMAT_ISO8601, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("DATE_RFC822", DATE_FORMAT_RFC822, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("DATE_RFC850", DATE_FORMAT_RFC850, CONST_CS | CONST_PERSISTENT);
@@ -1948,7 +1956,7 @@ static void date_register_classes(TSRMLS_D)
zend_declare_class_constant_stringl(date_ce_date, const_name, sizeof(const_name)-1, value, sizeof(value)-1 TSRMLS_CC);
REGISTER_DATE_CLASS_CONST_STRING("ATOM", DATE_FORMAT_RFC3339);
- REGISTER_DATE_CLASS_CONST_STRING("COOKIE", DATE_FORMAT_RFC850);
+ REGISTER_DATE_CLASS_CONST_STRING("COOKIE", DATE_FORMAT_COOKIE);
REGISTER_DATE_CLASS_CONST_STRING("ISO8601", DATE_FORMAT_ISO8601);
REGISTER_DATE_CLASS_CONST_STRING("RFC822", DATE_FORMAT_RFC822);
REGISTER_DATE_CLASS_CONST_STRING("RFC850", DATE_FORMAT_RFC850);
diff --git a/ext/date/tests/DateTime_format_basic2.phpt b/ext/date/tests/DateTime_format_basic2.phpt
index d7adaa5df8..016fa7b6b2 100644
--- a/ext/date/tests/DateTime_format_basic2.phpt
+++ b/ext/date/tests/DateTime_format_basic2.phpt
@@ -31,7 +31,7 @@ var_dump( $date->format( DateTime::W3C) ) ;
--EXPECT--
*** Testing date_format() : basic functionality - formatting coinstants ***
string(25) "2005-07-14T22:30:41+01:00"
-string(32) "Thursday, 14-Jul-05 22:30:41 BST"
+string(34) "Thursday, 14-Jul-2005 22:30:41 BST"
string(24) "2005-07-14T22:30:41+0100"
string(29) "Thu, 14 Jul 05 22:30:41 +0100"
string(32) "Thursday, 14-Jul-05 22:30:41 BST"
diff --git a/ext/date/tests/DateTime_verify.phpt b/ext/date/tests/DateTime_verify.phpt
index a03911f5c8..c790974729 100644
--- a/ext/date/tests/DateTime_verify.phpt
+++ b/ext/date/tests/DateTime_verify.phpt
@@ -160,7 +160,7 @@ array(11) {
["ATOM"]=>
string(13) "Y-m-d\TH:i:sP"
["COOKIE"]=>
- string(16) "l, d-M-y H:i:s T"
+ string(16) "l, d-M-Y H:i:s T"
["ISO8601"]=>
string(13) "Y-m-d\TH:i:sO"
["RFC822"]=>
@@ -180,4 +180,4 @@ array(11) {
["W3C"]=>
string(13) "Y-m-d\TH:i:sP"
}
-===DONE=== \ No newline at end of file
+===DONE===
diff --git a/ext/date/tests/bug52063.phpt b/ext/date/tests/bug52063.phpt
index af9da9e429..7364a80612 100644
--- a/ext/date/tests/bug52063.phpt
+++ b/ext/date/tests/bug52063.phpt
@@ -11,5 +11,5 @@ echo $a->format(DateTime::COOKIE);
echo "\n";
?>
--EXPECTF--
-Thursday, 01-Jan-09 00:00:00 WET
-Thursday, 01-Jan-09 00:00:00 WET
+Thursday, 01-Jan-2009 00:00:00 WET
+Thursday, 01-Jan-2009 00:00:00 WET
diff --git a/ext/date/tests/bug53879.phpt b/ext/date/tests/bug53879.phpt
new file mode 100644
index 0000000000..64c0f18fef
--- /dev/null
+++ b/ext/date/tests/bug53879.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #53879 (DateTime::createFromFormat() fails to parse cookie expiration date)
+--FILE--
+<?php
+$date = DateTime::createFromFormat(DateTime::COOKIE, "Mon, 21-Jan-2041 15:24:52 GMT");
+print_r($date);
+?>
+--EXPECTF--
+DateTime Object
+(
+ [date] => 2041-01-21 15:24:52
+ [timezone_type] => 2
+ [timezone] => GMT
+)
diff --git a/ext/date/tests/date_constants.phpt b/ext/date/tests/date_constants.phpt
index 132e24159b..b9fce8c78b 100644
--- a/ext/date/tests/date_constants.phpt
+++ b/ext/date/tests/date_constants.phpt
@@ -41,8 +41,8 @@ Date constants
--EXPECT--
string(25) "2006-07-01T14:27:30+02:00"
string(25) "2006-05-30T14:32:13+02:00"
-string(33) "Saturday, 01-Jul-06 14:27:30 CEST"
-string(32) "Tuesday, 30-May-06 14:32:13 CEST"
+string(35) "Saturday, 01-Jul-2006 14:27:30 CEST"
+string(34) "Tuesday, 30-May-2006 14:32:13 CEST"
string(24) "2006-07-01T14:27:30+0200"
string(24) "2006-05-30T14:32:13+0200"
string(29) "Sat, 01 Jul 06 14:27:30 +0200"
diff --git a/ext/date/tests/gmdate_variation13.phpt b/ext/date/tests/gmdate_variation13.phpt
index 5a19ae268e..1d1f434ece 100644
--- a/ext/date/tests/gmdate_variation13.phpt
+++ b/ext/date/tests/gmdate_variation13.phpt
@@ -45,7 +45,7 @@ string(25) "2008-08-08T08:08:08+00:00"
string(%d) "%s"
--DATE_COOKIE Constant--
-string(30) "Friday, 08-Aug-08 08:08:08 GMT"
+string(32) "Friday, 08-Aug-2008 08:08:08 GMT"
string(%d) "%s"
--DATE_RFC822 Constant--
@@ -79,4 +79,4 @@ string(%d) "%s"
--DATE_W3C Constant--
string(25) "2008-08-08T08:08:08+00:00"
string(%d) "%s"
-===DONE=== \ No newline at end of file
+===DONE===
diff --git a/ext/date/tests/test-parse-from-format.phpt b/ext/date/tests/test-parse-from-format.phpt
index 2bf9c4e1b8..5bb5fe5325 100644
--- a/ext/date/tests/test-parse-from-format.phpt
+++ b/ext/date/tests/test-parse-from-format.phpt
@@ -32,8 +32,8 @@ object(DateTime)#2 (3) {
string(6) "+02:00"
}
-string(16) "l, d-M-y H:i:s T"
-string(36) "Tuesday, 08-Jul-08 22:14:12 GMT+0200"
+string(16) "l, d-M-Y H:i:s T"
+string(38) "Tuesday, 08-Jul-2008 22:14:12 GMT+0200"
object(DateTime)#1 (3) {
["date"]=>
string(19) "2008-07-08 22:14:12"