From: Michael Wallner Date: Thu, 16 Jan 2014 22:49:28 +0000 (+0100) Subject: fix regression X-Git-Tag: RELEASE_2_1_0_RC1~48 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=3aba2100e0b6ae8f34f688825d1c00d69175dd53;p=m6w6%2Fext-http fix regression --- diff --git a/php_http_params.c b/php_http_params.c index faa3cbb..4b02e8c 100644 --- a/php_http_params.c +++ b/php_http_params.c @@ -741,12 +741,13 @@ static inline void shift_val(php_http_buffer_t *buf, zval *zvalue, const char *v } } -static void shift_arg(php_http_buffer_t *buf, char *key_str, size_t key_len, zval *zvalue, const char *ass, size_t asl, const char *vss, size_t vsl, unsigned flags, zend_bool rfc5987 TSRMLS_DC) +static void shift_arg(php_http_buffer_t *buf, char *key_str, size_t key_len, zval *zvalue, const char *ass, size_t asl, const char *vss, size_t vsl, unsigned flags TSRMLS_DC) { if (Z_TYPE_P(zvalue) == IS_ARRAY || Z_TYPE_P(zvalue) == IS_OBJECT) { HashPosition pos; php_http_array_hashkey_t key = php_http_array_hashkey_init(0); zval **val; + zend_bool rfc5987 = !strcmp(key_str, "*rfc5987*"); if (!rfc5987) { shift_key(buf, key_str, key_len, ass, asl, flags TSRMLS_CC); @@ -758,7 +759,7 @@ static void shift_arg(php_http_buffer_t *buf, char *key_str, size_t key_len, zva shift_key(buf, key.str, key.len-1, ass, asl, flags TSRMLS_CC); shift_rfc5987(buf, *val, vss, vsl, flags TSRMLS_CC); } else { - shift_arg(buf, key.str, key.len-1, *val, ass, asl, vss, vsl, flags, 0 TSRMLS_CC); + shift_arg(buf, key.str, key.len-1, *val, ass, asl, vss, vsl, flags TSRMLS_CC); } php_http_array_hashkey_stringfree(&key); } @@ -768,7 +769,7 @@ static void shift_arg(php_http_buffer_t *buf, char *key_str, size_t key_len, zva } } -static void shift_param(php_http_buffer_t *buf, char *key_str, size_t key_len, zval *zvalue, const char *pss, size_t psl, const char *ass, size_t asl, const char *vss, size_t vsl, unsigned flags TSRMLS_DC) +static void shift_param(php_http_buffer_t *buf, char *key_str, size_t key_len, zval *zvalue, const char *pss, size_t psl, const char *ass, size_t asl, const char *vss, size_t vsl, unsigned flags, zend_bool rfc5987 TSRMLS_DC) { if (Z_TYPE_P(zvalue) == IS_ARRAY || Z_TYPE_P(zvalue) == IS_OBJECT) { /* treat as arguments, unless we care for dimensions or rfc5987 */ @@ -776,11 +777,11 @@ static void shift_param(php_http_buffer_t *buf, char *key_str, size_t key_len, z php_http_buffer_t *keybuf = php_http_buffer_from_string(key_str, key_len); prepare_dimension(buf, keybuf, zvalue, pss, psl, vss, vsl, flags TSRMLS_CC); php_http_buffer_free(&keybuf); - } else if (flags & PHP_HTTP_PARAMS_RFC5987) { + } else if (rfc5987) { shift_key(buf, key_str, key_len, pss, psl, flags TSRMLS_CC); shift_rfc5987(buf, zvalue, vss, vsl, flags TSRMLS_CC); } else { - shift_arg(buf, key_str, key_len, zvalue, ass, asl, vss, vsl, flags, 0 TSRMLS_CC); + shift_arg(buf, key_str, key_len, zvalue, ass, asl, vss, vsl, flags TSRMLS_CC); } } else { shift_key(buf, key_str, key_len, pss, psl, flags TSRMLS_CC); @@ -793,6 +794,7 @@ php_http_buffer_t *php_http_params_to_string(php_http_buffer_t *buf, HashTable * zval **zparam; HashPosition pos, pos1; php_http_array_hashkey_t key = php_http_array_hashkey_init(0), key1 = php_http_array_hashkey_init(0); + zend_bool rfc5987 = 0; if (!buf) { buf = php_http_buffer_init(NULL); @@ -807,12 +809,14 @@ php_http_buffer_t *php_http_params_to_string(php_http_buffer_t *buf, HashTable * if (SUCCESS != zend_hash_find(Z_ARRVAL_PP(zparam), ZEND_STRS("value"), (void *) &zvalue)) { if (SUCCESS != zend_hash_find(Z_ARRVAL_PP(zparam), ZEND_STRS("*rfc5987*"), (void *) &zvalue)) { zvalue = zparam; + } else { + rfc5987 = 1; } } } php_http_array_hashkey_stringify(&key); - shift_param(buf, key.str, key.len - 1, *zvalue, pss, psl, ass, asl, vss, vsl, flags TSRMLS_CC); + shift_param(buf, key.str, key.len - 1, *zvalue, pss, psl, ass, asl, vss, vsl, flags, rfc5987 TSRMLS_CC); php_http_array_hashkey_stringfree(&key); if (Z_TYPE_PP(zparam) == IS_ARRAY && SUCCESS != zend_hash_find(Z_ARRVAL_PP(zparam), ZEND_STRS("arguments"), (void *) &zvalue)) { @@ -829,8 +833,7 @@ php_http_buffer_t *php_http_params_to_string(php_http_buffer_t *buf, HashTable * } php_http_array_hashkey_stringify(&key1); - shift_arg(buf, key1.str, key1.len - 1, *zargs, ass, asl, vss, vsl, flags, - HASH_KEY_IS_STRING == key1.type && !strcmp(key1.str, "*rfc5987*") TSRMLS_CC); + shift_arg(buf, key1.str, key1.len - 1, *zargs, ass, asl, vss, vsl, flags TSRMLS_CC); php_http_array_hashkey_stringfree(&key1); } } diff --git a/tests/params004.phpt b/tests/params004.phpt index 680c055..b61953d 100644 --- a/tests/params004.phpt +++ b/tests/params004.phpt @@ -12,7 +12,7 @@ $s = urlencode("ß"); $t = "p1*=utf-8''s$u$s,p2*=utf-8''hei$s;a1*=utf-8''a$s;a2*=utf-8''e$s;a3=no,p3=not"; $p = new http\Params($t); var_dump($p->params); -var_dump((string)$p === $t); +var_dump((string)$p === $t, (string)$p, $t); ?> ===DONE=== --EXPECT-- @@ -65,4 +65,6 @@ array(3) { } } bool(true) +string(96) "p1*=utf-8''s%C3%BC%C3%9F,p2*=utf-8''hei%C3%9F;a1*=utf-8''a%C3%9F;a2*=utf-8''e%C3%9F;a3=no,p3=not" +string(96) "p1*=utf-8''s%C3%BC%C3%9F,p2*=utf-8''hei%C3%9F;a1*=utf-8''a%C3%9F;a2*=utf-8''e%C3%9F;a3=no,p3=not" ===DONE=== diff --git a/tests/params005.phpt b/tests/params005.phpt new file mode 100644 index 0000000..ad3948c --- /dev/null +++ b/tests/params005.phpt @@ -0,0 +1,25 @@ +--TEST-- +header params rfc5987 regression +--SKIPIF-- + +--FILE-- +["filename"=>"foo.bar"]]); +var_dump($p->params); +var_dump((string)$p); +?> +===DONE=== +--EXPECT-- +Test +array(1) { + ["attachment"]=> + array(1) { + ["filename"]=> + string(7) "foo.bar" + } +} +string(27) "attachment;filename=foo.bar" +===DONE===