- really fix http_parse_cookie()
authorMichael Wallner <mike@php.net>
Wed, 15 Feb 2006 18:44:12 +0000 (18:44 +0000)
committerMichael Wallner <mike@php.net>
Wed, 15 Feb 2006 18:44:12 +0000 (18:44 +0000)
- fix version info in main header file
- release .23.1

http_cookie_api.c
package.xml
package2.xml
php_http.h
tests/parse_cookie_002.phpt [new file with mode: 0644]

index fb3a9505c438634d03b94082867835f5eaa971d0..bf9af4048c74cfae088374c8b475f52583257c67 100644 (file)
@@ -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;
index d3446d5cd9ba91fa804c17db6c697bac484fe422..2b6ad1cca73b7702192aa365b98f08dcdf8c7014 100644 (file)
@@ -30,24 +30,11 @@ HttpResponse
   </maintainer>
   </maintainers>
  <release>
-  <version>0.23.0</version>
+  <version>0.23.1</version>
   <date>2006-02-15</date>
   <license>BSD, revised</license>
   <state>beta</state>
-  <notes>+ Added &apos;etag&apos; request option.
-+ Added &apos;encodecookies&apos; 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 &quot;resolve&quot; 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.
+  <notes>* Fixed http_parse_cookie(), really.
   </notes>
   <deps>
    <dep type="php" rel="ge" version="4.3"/>
@@ -143,6 +130,7 @@ HttpResponse
     <file role="test" name="ob_deflatehandler_001.phpt"/>
     <file role="test" name="ob_inflatehandler_001.phpt"/>
     <file role="test" name="parse_cookie_001.phpt"/>
+    <file role="test" name="parse_cookie_002.phpt"/>
     <file role="test" name="parse_headers_001.phpt"/>
     <file role="test" name="parse_message_001.phpt"/>
     <file role="test" name="parse_message_002.phpt"/>
index 09fab0a73d2cc88d7642209ea1508b81d5cdefd7..e805ba192ac902f3cb9fc76fcaf1dc2c277f502e 100644 (file)
@@ -37,7 +37,7 @@ HttpResponse
  </lead>
  <date>2006-00-00</date>
  <version>
-  <release>0.23.0</release>
+  <release>0.23.1</release>
   <api>0.23.0</api>
  </version>
  <stability>
@@ -46,20 +46,7 @@ HttpResponse
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
-+ 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.
 ]]></notes>
  <contents>
   <dir name="/">
@@ -213,6 +200,7 @@ HttpResponse
     <file role="test" name="ob_deflatehandler_001.phpt"/>
     <file role="test" name="ob_inflatehandler_001.phpt"/>
     <file role="test" name="parse_cookie_001.phpt"/>
+    <file role="test" name="parse_cookie_002.phpt"/>
     <file role="test" name="parse_headers_001.phpt"/>
     <file role="test" name="parse_message_001.phpt"/>
     <file role="test" name="parse_message_002.phpt"/>
index 7302098ea1fa4a02308255c30ba11c6ca1ae1eed..6df82088bbae7cb3ed25aade59d8dde1cd900ffe 100644 (file)
@@ -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 (file)
index 0000000..3aa38f2
--- /dev/null
@@ -0,0 +1,79 @@
+--TEST--
+parse cookie
+--SKIPIF--
+<?php
+include 'skip.inc';
+?>
+--FILE--
+<?php
+echo "-TEST\n";
+
+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= ;')->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