summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2005-07-08 12:30:24 +0000
committerAntony Dovgal <tony2001@php.net>2005-07-08 12:30:24 +0000
commit592a0835fa9634134d14d62f24a39a67360d49a5 (patch)
tree7aef69cc4f86d116e45f21abebae92e3fff1e4e6
parent39379b8f58eeab32fa5d190bffcd36b73c97e0a7 (diff)
downloadphp-git-592a0835fa9634134d14d62f24a39a67360d49a5.tar.gz
fix #33597 (setcookie() "expires" date format doesn't comply with RFC)
-rw-r--r--NEWS2
-rw-r--r--ext/standard/head.c8
2 files changed, 7 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 787fda0e08..1acf2b6193 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,8 @@ PHP NEWS
- Fixed crash inside stream_get_line() when length parameter equals 0. (Ilia)
- Fixed bug #33605 (substr_compare() crashes with negative offset and length).
(Tony)
+- Fixed bug #33597 (setcookie() "expires" date format doesn't comply with RFC).
+ (Tony)
- Fixed bug #33578 (strtotime() doesn't understand "11 Oct" format). (Derick)
- Fixed bug #33562 (date("") crashes). (Derick)
- Fixed bug #33536 (strtotime() defaults to now even on non time string).
diff --git a/ext/standard/head.c b/ext/standard/head.c
index e8e0486cfc..6fe646e8b3 100644
--- a/ext/standard/head.c
+++ b/ext/standard/head.c
@@ -20,6 +20,7 @@
#include <stdio.h>
#include "php.h"
#include "ext/standard/php_standard.h"
+#include "ext/date/php_date.h"
#include "SAPI.h"
#include "php_main.h"
#include "head.h"
@@ -103,15 +104,16 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
* pick an expiry date 1 year and 1 second in the past
*/
t = time(NULL) - 31536001;
- dt = php_std_date(t TSRMLS_CC);
- sprintf(cookie, "Set-Cookie: %s=deleted; expires=%s", name, dt);
+ dt = php_format_date("D, d-M-Y H:i:s", sizeof("D, d-M-Y H:i:s")-1, t, 0);
+ sprintf(cookie, "Set-Cookie: %s=deleted; expires=%s GMT", name, dt);
efree(dt);
} else {
sprintf(cookie, "Set-Cookie: %s=%s", name, value ? encoded_value : "");
if (expires > 0) {
strcat(cookie, "; expires=");
- dt = php_std_date(expires TSRMLS_CC);
+ dt = php_format_date("D, d-M-Y H:i:s", sizeof("D, d-M-Y H:i:s")-1, t, 0);
strcat(cookie, dt);
+ strcat(cookie, " GMT");
efree(dt);
}
}