From: Michael Wallner Date: Wed, 15 Feb 2006 18:44:12 +0000 (+0000) Subject: - really fix http_parse_cookie() X-Git-Tag: RELEASE_0_23_1~1 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=0861238aa4d158d0f8b6123ea9c6532be5d531bf;p=m6w6%2Fext-http - really fix http_parse_cookie() - fix version info in main header file - release .23.1 --- diff --git a/http_cookie_api.c b/http_cookie_api.c index fb3a950..bf9af40 100644 --- a/http_cookie_api.c +++ b/http_cookie_api.c @@ -185,11 +185,13 @@ PHP_HTTP_API http_cookie_list *_http_parse_cookie_ex(http_cookie_list *list, con switch (st) { case ST_QUOTE: + quote: if (*c == '"') { - if (*(c-1) != '\\') { - st = ST_ADD; - } else { + if (*(c-1) == '\\') { memmove(c-1, c, strlen(c)+1); + goto quote; + } else { + goto add; } } else { if (!val) { @@ -215,10 +217,8 @@ PHP_HTTP_API http_cookie_list *_http_parse_cookie_ex(http_cookie_list *list, con break; case ';': - if (!*(c+1)) { - goto add; - } case '\0': + goto add; st = ST_ADD; break; @@ -288,8 +288,9 @@ PHP_HTTP_API http_cookie_list *_http_parse_cookie_ex(http_cookie_list *list, con add: if (val) { vallen = c - val; - if (*c) --vallen; - while (val[vallen-1] == ' ') --vallen; + if (st != ST_QUOTE) { + while (val[vallen-1] == ' ') --vallen; + } } else { val = ""; vallen = 0; diff --git a/package.xml b/package.xml index d3446d5..2b6ad1c 100644 --- a/package.xml +++ b/package.xml @@ -30,24 +30,11 @@ HttpResponse - 0.23.0 + 0.23.1 2006-02-15 BSD, revised beta - + Added 'etag' request option. -+ Added 'encodecookies' request option (defaults to true). -+ Added missing accessors for response status text to HttpMessage and HttpRequest classes. -+ Added HttpMessage::reverse(). -+ Added bool must_revalidate parameter to HttpResponse::setCacheControl() - -- Reimplemented http_parse_cookie(). -- Changed HttpRequest::getResponseCookie() to HttpRequest::getResponseCookies(), - compliant to http_parse_cookie(). -- http_build_url() now tries to "resolve" public hostname prior falling back - to localhost if neither HTTP_HOST nor SERVER_NAME is set. -- Changed HttpRequest::getHistory() to return a real property. - -* Fixed PHP-4.4 and PHP-5.0 build. + * Fixed http_parse_cookie(), really. @@ -143,6 +130,7 @@ HttpResponse + diff --git a/package2.xml b/package2.xml index 09fab0a..e805ba1 100644 --- a/package2.xml +++ b/package2.xml @@ -37,7 +37,7 @@ HttpResponse 2006-00-00 - 0.23.0 + 0.23.1 0.23.0 @@ -46,20 +46,7 @@ HttpResponse BSD, revised @@ -213,6 +200,7 @@ HttpResponse + diff --git a/php_http.h b/php_http.h index 7302098..6df8208 100644 --- a/php_http.h +++ b/php_http.h @@ -15,7 +15,7 @@ #ifndef PHP_EXT_HTTP_H #define PHP_EXT_HTTP_H -#define PHP_EXT_HTTP_VERSION "0.23.0dev" +#define PHP_EXT_HTTP_VERSION "0.23.1" #ifdef HAVE_CONFIG_H # include "config.h" diff --git a/tests/parse_cookie_002.phpt b/tests/parse_cookie_002.phpt new file mode 100644 index 0000000..3aa38f2 --- /dev/null +++ b/tests/parse_cookie_002.phpt @@ -0,0 +1,79 @@ +--TEST-- +parse cookie +--SKIPIF-- + +--FILE-- +cookies['foo']); +var_dump(http_parse_cookie('foo;')->cookies['foo']); +var_dump(http_parse_cookie('foo ')->cookies['foo']); +var_dump(http_parse_cookie('foo ;')->cookies['foo']); +var_dump(http_parse_cookie('foo ; ')->cookies['foo']); +var_dump(http_parse_cookie('foo=')->cookies['foo']); +var_dump(http_parse_cookie('foo=;')->cookies['foo']); +var_dump(http_parse_cookie('foo =')->cookies['foo']); +var_dump(http_parse_cookie('foo =;')->cookies['foo']); +var_dump(http_parse_cookie('foo= ')->cookies['foo']); +var_dump(http_parse_cookie('foo= ;')->cookies['foo']); + +var_dump(http_parse_cookie('foo=1')->cookies['foo']); +var_dump(http_parse_cookie('foo=1;')->cookies['foo']); +var_dump(http_parse_cookie('foo=1 ;')->cookies['foo']); +var_dump(http_parse_cookie('foo= 1;')->cookies['foo']); +var_dump(http_parse_cookie('foo = 1;')->cookies['foo']); +var_dump(http_parse_cookie('foo = 1 ;')->cookies['foo']); +var_dump(http_parse_cookie('foo=1')->cookies['foo']); +var_dump(http_parse_cookie('foo= 1')->cookies['foo']); + +var_dump(http_parse_cookie('foo="1"')->cookies['foo']); +var_dump(http_parse_cookie('foo="1" ')->cookies['foo']); +var_dump(http_parse_cookie('foo="1";')->cookies['foo']); +var_dump(http_parse_cookie('foo = "1" ;')->cookies['foo']); +var_dump(http_parse_cookie('foo= "1" ')->cookies['foo']); + +var_dump(http_parse_cookie('foo=""')->cookies['foo']); +var_dump(http_parse_cookie('foo="\""')->cookies['foo']); +var_dump(http_parse_cookie('foo=" "')->cookies['foo']); +var_dump(http_parse_cookie('foo= "')->cookies['foo']); +var_dump(http_parse_cookie('foo=" ')->cookies['foo']); +var_dump(http_parse_cookie('foo= " ')->cookies['foo']); + +echo "Done\n"; +?> +--EXPECTF-- +%sTEST +string(0) "" +string(0) "" +string(0) "" +string(0) "" +string(0) "" +string(0) "" +string(0) "" +string(0) "" +string(0) "" +string(0) "" +string(0) "" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(0) "" +string(1) """ +string(1) " " +string(1) """ +string(1) """ +string(1) """ +Done