fix for 7.3.0alpha4
authorRemi Collet <remi@remirepo.net>
Wed, 18 Jul 2018 04:37:53 +0000 (06:37 +0200)
committerRemi Collet <remi@remirepo.net>
Wed, 18 Jul 2018 04:37:53 +0000 (06:37 +0200)
src/php_http_header_parser.c
src/php_http_message_body.c
src/php_http_params.c

index b97ae6b62796b6e5e58f6ebb45f53fed4884eac7..cd76b763cc6b4642c2256265077480d830c67ab9 100644 (file)
@@ -74,9 +74,14 @@ void php_http_header_parser_free(php_http_header_parser_t **parser)
 /* NOTE: 'str' has to be null terminated */
 static void php_http_header_parser_error(size_t valid_len, char *str, size_t len, const char *eol_str )
 {
-       zend_string *escaped_str = zend_string_init(str, len, 0);
+       zend_string *escaped_str, *zstr_str = zend_string_init(str, len, 0);
 
-       escaped_str = php_addcslashes(escaped_str, 1, ZEND_STRL("\x0..\x1F\x7F..\xFF"));
+#if PHP_VERSION_ID < 70300
+       escaped_str = php_addcslashes(zstr_str, 1, ZEND_STRL("\x0..\x1F\x7F..\xFF"));
+#else
+       escaped_str = php_addcslashes(zstr_str, ZEND_STRL("\x0..\x1F\x7F..\xFF"));
+       zend_string_release_ex(zstr_str, 0);
+#endif
 
        if (valid_len != len && (!eol_str || (str+valid_len) != eol_str)) {
                php_error_docref(NULL, E_WARNING, "Failed to parse headers: unexpected character '\\%03o' at pos %zu of '%s'", str[valid_len], valid_len, escaped_str->val);
index 526c233f18af4a3aebaabfcb1f7d4ba49f52063f..518dbc9b71ef34b57362a63463a2f100c7d5e3b7 100644 (file)
@@ -262,9 +262,14 @@ void php_http_message_body_add_part(php_http_message_body_t *body, php_http_mess
 
 ZEND_RESULT_CODE php_http_message_body_add_form_field(php_http_message_body_t *body, const char *name, const char *value_str, size_t value_len)
 {
-       zend_string *safe_name = zend_string_init(name, strlen(name), 0);
+       zend_string *safe_name, *zstr_name = zend_string_init(name, strlen(name), 0);
 
-       safe_name = php_addslashes(safe_name, 1);
+#if PHP_VERSION_ID < 70300
+       safe_name = php_addslashes(zstr_name, 1);
+#else
+       safe_name = php_addslashes(zstr_name);
+       zend_string_release_ex(zstr_name, 0);
+#endif
 
        BOUNDARY_OPEN(body);
        php_http_message_body_appendf(
@@ -284,9 +289,14 @@ ZEND_RESULT_CODE php_http_message_body_add_form_file(php_http_message_body_t *bo
 {
        size_t path_len = strlen(path);
        char *path_dup = estrndup(path, path_len);
-       zend_string *base_name, *safe_name = zend_string_init(name, strlen(name), 0);
-
-       safe_name = php_addslashes(safe_name, 1);
+       zend_string *base_name, *safe_name, *zstr_name = zend_string_init(name, strlen(name), 0);
+
+#if PHP_VERSION_ID < 70300
+       safe_name = php_addslashes(zstr_name, 1);
+#else
+       safe_name = php_addslashes(zstr_name);
+       zend_string_release_ex(zstr_name, 0);
+#endif
        base_name = php_basename(path_dup, path_len, NULL, 0);
 
        BOUNDARY_OPEN(body);
index b22769ef7531af5ac4dea2fc591deb618e0da77c..0cbfc7e81e92b02f00060077de27829c21b1cd2f 100644 (file)
@@ -67,7 +67,11 @@ static inline zend_string *quote_string(zend_string *zs, zend_bool force)
 {
        size_t len = (zs)->len;
 
+#if PHP_VERSION_ID < 70300
        zs = php_addcslashes(zs, 0, ZEND_STRL("\0..\37\173\\\""));
+#else
+       zs = php_addcslashes(zs, ZEND_STRL("\0..\37\173\\\""));
+#endif
 
        if (force || len != (zs)->len || strpbrk((zs)->val, "()<>@,;:\"[]?={} ")) {
                int len = (zs)->len + 2;