- fix errenous bailout of http_parse_headers() introduced with last commit
authorMichael Wallner <mike@php.net>
Wed, 5 Apr 2006 14:48:39 +0000 (14:48 +0000)
committerMichael Wallner <mike@php.net>
Wed, 5 Apr 2006 14:48:39 +0000 (14:48 +0000)
http_headers_api.c

index 7ac475692aff101d66d18fd7d0ca278350686bd6..a5448a995c1a79eb86c442795e9040db8d8a17e0 100644 (file)
@@ -328,9 +328,10 @@ PHP_HTTP_API STATUS _http_parse_headers_ex(const char *header, HashTable *header
 {
        const char *colon = NULL, *line = header;
        zval array;
-
+       
        INIT_ZARR(array, headers);
        
+#define MORE_HEADERS (*(line-1) && !(*(line-1) == '\n' && (*line == '\n' || *line == '\r')))
        do {
                int value_len = 0;
                
@@ -353,11 +354,8 @@ PHP_HTTP_API STATUS _http_parse_headers_ex(const char *header, HashTable *header
                                                callback_func(callback_data, &headers, &i TSRMLS_CC);
                                                http_info_dtor(&i);
                                                Z_ARRVAL(array) = headers;
-                                       } else
-                                       
-                                       /* "header: value" pair */
-                                       if (colon) {
-
+                                       } else if (colon) {
+                                               /* "header: value" pair */
                                                /* skip empty key */
                                                if (header != colon) {
                                                        zval **previous = NULL;
@@ -395,7 +393,7 @@ PHP_HTTP_API STATUS _http_parse_headers_ex(const char *header, HashTable *header
                                                        }
                                                        efree(key);
                                                }
-                                       } else {
+                                       } else if (MORE_HEADERS) {
                                                return FAILURE;
                                        }
                                        colon = NULL;
@@ -404,7 +402,7 @@ PHP_HTTP_API STATUS _http_parse_headers_ex(const char *header, HashTable *header
                                }
                        break;
                }
-       } while (*(line-1) && !(*(line-1) == '\n' && (*line == '\n' || *line == '\r')));
+       } while (MORE_HEADERS);
 
        return SUCCESS;
 }