* Fixed Bug #64310 (weak etags W/"abc" are quoted as "W/"abc"")
authorMichael Wallner <mike@php.net>
Sat, 2 Mar 2013 20:13:19 +0000 (20:13 +0000)
committerMichael Wallner <mike@php.net>
Sat, 2 Mar 2013 20:13:19 +0000 (20:13 +0000)
http_request_api.c
package.xml
php_http.h

index 1b0c59e522a2120785601c222ab19c0d24664f13..b6e40344c27001aeba102f149c63ea4b164af5a2 100644 (file)
@@ -872,12 +872,29 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
        }
        /* etag */
        if ((zoption = http_request_option(request, options, "etag", IS_STRING)) && Z_STRLEN_P(zoption)) {
-               zend_bool is_quoted = !((Z_STRVAL_P(zoption)[0] != '"') || (Z_STRVAL_P(zoption)[Z_STRLEN_P(zoption)-1] != '"'));
+               zend_bool is_quoted;
                phpstr header;
-               
+
                phpstr_init(&header);
-               phpstr_appendf(&header, is_quoted?"%s: %s":"%s: \"%s\"", range_req?"If-Match":"If-None-Match", Z_STRVAL_P(zoption));
+               phpstr_appendf(&header, "%s: ", range_req?"If-Match":"If-None-Match");
+               if ((Z_STRVAL_P(zoption)[0] == '"') && (Z_STRVAL_P(zoption)[Z_STRLEN_P(zoption)-1] == '"')) {
+                       /* properly quoted etag */
+                       phpstr_append(&header, Z_STRVAL_P(zoption), Z_STRLEN_P(zoption));
+               } else if ((Z_STRVAL_P(zoption)[0] == 'W') && (Z_STRVAL_P(zoption)[1] == '/')) {
+                       /* weak etag */
+                       if ((Z_STRLEN_P(zoption) > 3) && (Z_STRVAL_P(zoption)[2] == '"') && (Z_STRVAL_P(zoption)[Z_STRLEN_P(zoption)-1] == '"')) {
+                               /* quoted */
+                               phpstr_append(&header, Z_STRVAL_P(zoption), Z_STRLEN_P(zoption));
+                       } else {
+                               /* unquoted */
+                               phpstr_appendf(&header, "W/\"%s\"", Z_STRVAL_P(zoption) + 2);
+                       }
+               } else {
+                       /* assume unquoted etag */
+                       phpstr_appendf(&header, "\"%s\"", Z_STRVAL_P(zoption));
+               }
                phpstr_fix(&header);
+
                request->_cache.headers = curl_slist_append(request->_cache.headers, PHPSTR_VAL(&header));
                phpstr_dtor(&header);
        }
index 144043839d5303da3fbbe4dd486f0bc12b3317db..4adfb6fc6b85bd8b396f2f51208282fa26568f04 100644 (file)
@@ -28,9 +28,9 @@ support. Parallel requests are available for PHP 5 and greater.
   <email>mike@php.net</email>
   <active>yes</active>
  </lead>
- <date>2012-04-02</date>
+ <date>2013-03-02</date>
  <version>
-  <release>1.7.4</release>
+  <release>1.7.5dev</release>
   <api>1.7.0</api>
  </version>
  <stability>
@@ -39,7 +39,7 @@ support. Parallel requests are available for PHP 5 and greater.
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
-* Fixed Bug #61372 (build fails with "undefined symbol Z_ADDREF_P)
+* Fixed Bug #64310 (weak etags W/"abc" are quoted as "W/"abc"")
 ]]></notes>
  <contents>
   <dir name="/">
index 0762c076deb483804dacecb55fc248726b736aac..023be4ffe8392f8fc348309a6e0ddb37f4cfa2d8 100644 (file)
@@ -15,7 +15,7 @@
 #ifndef PHP_EXT_HTTP_H
 #define PHP_EXT_HTTP_H
 
-#define PHP_HTTP_VERSION "1.7.4"
+#define PHP_HTTP_VERSION "1.7.5dev"
 
 #ifdef HAVE_CONFIG_H
 #      include "config.h"