The comment was slightly misleading. setcookie() was not changed at all.
A second function (setrawcookie) which doesn't do any urlencoding of the
data was simply added. The changes inside the setcookie() function was
just to re-use the same code but add a flag to set whether or not
urlencoding should be done.
Without setrawcookie() there is no easy way to set a cookie with data that
has already been escaped short of unescaping and re-escaping it.
-Rasmus
On Thu, 21 Aug 2003, Jani Taskinen wrote:
>
> When/where was this discussed? Why is this necessary?
> setcookie() works just fine as it was..
>
> --Jani
>
>
> On Wed, 20 Aug 2003, Brian France wrote:
>
> >bfrance Wed Aug 20 16:51:11 2003 EDT
> >
> > Modified files:
> > /php-src/ext/standard head.h head.c basic_functions.c
> > Log:
> >
> > Added a parameter to php_setcookie to toggle URL encoding of the cookie data
> > Added the function setrawcookie that turns off URL encoding of the cookie data
> > Changed setcookie to turn on the URL encoding of the cookie data
> >
> >
> >
> >Index: php-src/ext/standard/head.h
> >diff -u php-src/ext/standard/head.h:1.24 php-src/ext/standard/head.h:1.25
> >--- php-src/ext/standard/head.h:1.24 Tue Jun 10 16:03:37 2003
> >+++ php-src/ext/standard/head.h Wed Aug 20 16:51:10 2003
> >@@ -16,7 +16,7 @@
> > +----------------------------------------------------------------------+
> > */
> >
> >-/* $Id: head.h,v 1.24 2003/06/10 20:03:37 imajes Exp $ */
> >+/* $Id: head.h,v 1.25 2003/08/20 20:51:10 bfrance Exp $ */
> >
> > #ifndef HEAD_H
> > #define HEAD_H
> >@@ -24,9 +24,10 @@
> > extern PHP_RINIT_FUNCTION(head);
> > PHP_FUNCTION(header);
> > PHP_FUNCTION(setcookie);
> >+PHP_FUNCTION(setrawcookie);
> > PHP_FUNCTION(headers_sent);
> >
> > PHPAPI int php_header(TSRMLS_D);
> >-PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len,
> >time_t expires, char *path, int path_len, char *domain, int domain_len, int secure
> >TSRMLS_DC);
> >+PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len,
> >time_t expires, char *path, int path_len, char *domain, int domain_len, int secure,
> >int url_encode TSRMLS_DC);
> >
> > #endif
> >Index: php-src/ext/standard/head.c
> >diff -u php-src/ext/standard/head.c:1.70 php-src/ext/standard/head.c:1.71
> >--- php-src/ext/standard/head.c:1.70 Tue Jun 10 16:03:37 2003
> >+++ php-src/ext/standard/head.c Wed Aug 20 16:51:10 2003
> >@@ -15,7 +15,7 @@
> > | Author: Rasmus Lerdorf <[EMAIL PROTECTED]> |
> > +----------------------------------------------------------------------+
> > */
> >-/* $Id: head.c,v 1.70 2003/06/10 20:03:37 imajes Exp $ */
> >+/* $Id: head.c,v 1.71 2003/08/20 20:51:10 bfrance Exp $ */
> >
> > #include <stdio.h>
> >
> >@@ -65,7 +65,7 @@
> > }
> >
> >
> >-PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len,
> >time_t expires, char *path, int path_len, char *domain, int domain_len, int secure
> >TSRMLS_DC)
> >+PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len,
> >time_t expires, char *path, int path_len, char *domain, int domain_len, int secure,
> >int url_encode TSRMLS_DC)
> > {
> > char *cookie, *encoded_value = NULL;
> > int len=sizeof("Set-Cookie: ");
> >@@ -75,11 +75,14 @@
> > int result;
> >
> > len += name_len;
> >- if (value) {
> >+ if (value && url_encode) {
> > int encoded_value_len;
> >
> > encoded_value = php_url_encode(value, value_len, &encoded_value_len);
> > len += encoded_value_len;
> >+ } else if ( value ) {
> >+ encoded_value = estrdup(value);
> >+ len += value_len;
> > }
> > if (path) {
> > len += path_len;
> >@@ -150,7 +153,30 @@
> > return;
> > }
> >
> >- if (php_setcookie(name, name_len, value, value_len, expires, path, path_len,
> >domain, domain_len, secure TSRMLS_CC) == SUCCESS) {
> >+ if (php_setcookie(name, name_len, value, value_len, expires, path, path_len,
> >domain, domain_len, secure, 1 TSRMLS_CC) == SUCCESS) {
> >+ RETVAL_TRUE;
> >+ } else {
> >+ RETVAL_FALSE;
> >+ }
> >+}
> >+/* }}} */
> >+
> >+/* {{{ proto bool setrawcookie(string name [, string value [, int expires [,
> >string path [, string domain [, bool secure]]]]])
> >+ Send a cookie with no url encoding of the value */
> >+PHP_FUNCTION(setrawcookie)
> >+{
> >+ char *name, *value = NULL, *path = NULL, *domain = NULL;
> >+ long expires = 0;
> >+ zend_bool secure = 0;
> >+ int name_len, value_len, path_len, domain_len;
> >+
> >+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|slssb", &name,
> >+ &name_len, &value,
> >&value_len, &expires, &path,
> >+ &path_len, &domain,
> >&domain_len, &secure) == FAILURE) {
> >+ return;
> >+ }
> >+
> >+ if (php_setcookie(name, name_len, value, value_len, expires, path, path_len,
> >domain, domain_len, secure, 0 TSRMLS_CC) == SUCCESS) {
> > RETVAL_TRUE;
> > } else {
> > RETVAL_FALSE;
> >Index: php-src/ext/standard/basic_functions.c
> >diff -u php-src/ext/standard/basic_functions.c:1.622
> >php-src/ext/standard/basic_functions.c:1.623
> >--- php-src/ext/standard/basic_functions.c:1.622 Sun Aug 10 20:49:18 2003
> >+++ php-src/ext/standard/basic_functions.c Wed Aug 20 16:51:10 2003
> >@@ -17,7 +17,7 @@
> > +----------------------------------------------------------------------+
> > */
> >
> >-/* $Id: basic_functions.c,v 1.622 2003/08/11 00:49:18 sniper Exp $ */
> >+/* $Id: basic_functions.c,v 1.623 2003/08/20 20:51:10 bfrance Exp $ */
> >
> > #include "php.h"
> > #include "php_streams.h"
> >@@ -607,6 +607,7 @@
> > PHP_FE(restore_include_path,
> > NULL)
> >
> > PHP_FE(setcookie,
> > NULL)
> >+ PHP_FE(setrawcookie,
> > NULL)
> > PHP_FE(header,
> > NULL)
> > PHP_FE(headers_sent, first_and_second__args_force_ref)
> >
> >
> >
> >
> >
>
> --
> https://www.paypal.com/xclick/[EMAIL PROTECTED]&no_note=1&tax=0¤cy_code=EUR
>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php