projects
/
m6w6
/
ext-http
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
fix opcache weirdance
[m6w6/ext-http]
/
src
/
php_http_params.c
diff --git
a/src/php_http_params.c
b/src/php_http_params.c
index 8db5c353bd18c004ecc8bef617431577fafcb526..9f27918b36679d1dba298fa933e4ee768dbbebf0 100644
(file)
--- a/
src/php_http_params.c
+++ b/
src/php_http_params.c
@@
-63,24
+63,26
@@
static inline void sanitize_escaped(zval *zv)
php_stripcslashes(Z_STR_P(zv));
}
php_stripcslashes(Z_STR_P(zv));
}
-static inline
void quote_string(zend_string *
*zs, zend_bool force)
+static inline
zend_string *quote_string(zend_string
*zs, zend_bool force)
{
{
-
int len = (*
zs)->len;
+
size_t len = (
zs)->len;
-
*zs = php_addcslashes(*zs, 1
, ZEND_STRL("\0..\37\173\\\""));
+
zs = php_addcslashes(zs, 0
, ZEND_STRL("\0..\37\173\\\""));
- if (force || len != (
*zs)->len || strpbrk((*
zs)->val, "()<>@,;:\"[]?={} ")) {
- int len = (
*
zs)->len + 2;
+ if (force || len != (
zs)->len || strpbrk((
zs)->val, "()<>@,;:\"[]?={} ")) {
+ int len = (zs)->len + 2;
-
*zs = zend_string_extend(*
zs, len, 0);
+
zs = zend_string_extend(
zs, len, 0);
- memmove(&(
*zs)->val[1], (*zs)->val, (*
zs)->len);
- (
*
zs)->val[0] = '"';
- (
*
zs)->val[len-1] = '"';
- (
*
zs)->val[len] = '\0';
+ memmove(&(
zs)->val[1], (zs)->val, (
zs)->len);
+ (zs)->val[0] = '"';
+ (zs)->val[len-1] = '"';
+ (zs)->val[len] = '\0';
- zend_string_forget_hash_val(
*
zs);
+ zend_string_forget_hash_val(zs);
}
}
+
+ return zs;
}
/* if (Z_TYPE_P(zv) == IS_STRING) {
}
/* if (Z_TYPE_P(zv) == IS_STRING) {
@@
-109,7
+111,10
@@
static inline void quote_string(zend_string **zs, zend_bool force)
static inline void prepare_escaped(zval *zv)
{
if (Z_TYPE_P(zv) == IS_STRING) {
static inline void prepare_escaped(zval *zv)
{
if (Z_TYPE_P(zv) == IS_STRING) {
- quote_string(&Z_STR_P(zv), 0);
+ zend_string *str = quote_string(Z_STR_P(zv), 0);
+
+ zval_dtor(zv);
+ ZVAL_STR(zv, str);
} else {
zval_dtor(zv);
ZVAL_EMPTY_STRING(zv);
} else {
zval_dtor(zv);
ZVAL_EMPTY_STRING(zv);
@@
-248,16
+253,18
@@
static inline void sanitize_key(unsigned flags, const char *str, size_t len, zva
if (flags & PHP_HTTP_PARAMS_ESCAPED) {
sanitize_escaped(zv);
}
if (flags & PHP_HTTP_PARAMS_ESCAPED) {
sanitize_escaped(zv);
}
-
+
if (!Z_STRLEN_P(zv)) {
return;
}
if (!Z_STRLEN_P(zv)) {
return;
}
- eos = &Z_STRVAL_P(zv)[Z_STRLEN_P(zv)-1];
- if (*eos == '*') {
- *eos = '\0';
- *rfc5987 = 1;
- Z_STRLEN_P(zv) -= 1;
+ if (flags & PHP_HTTP_PARAMS_RFC5987) {
+ eos = &Z_STRVAL_P(zv)[Z_STRLEN_P(zv)-1];
+ if (*eos == '*') {
+ *eos = '\0';
+ *rfc5987 = 1;
+ Z_STRLEN_P(zv) -= 1;
+ }
}
if (flags & PHP_HTTP_PARAMS_URLENCODED) {
}
if (flags & PHP_HTTP_PARAMS_URLENCODED) {
@@
-487,7
+494,7
@@
static void merge_param(HashTable *params, zval *zdata, zval **current_param, zv
zval *test_ptr;
while (Z_TYPE_P(zdata_ptr) == IS_ARRAY && (test_ptr = zend_hash_get_current_data(Z_ARRVAL_P(zdata_ptr)))) {
zval *test_ptr;
while (Z_TYPE_P(zdata_ptr) == IS_ARRAY && (test_ptr = zend_hash_get_current_data(Z_ARRVAL_P(zdata_ptr)))) {
- if (Z_TYPE_P(test_ptr) == IS_ARRAY) {
+ if (Z_TYPE_P(test_ptr) == IS_ARRAY
&& Z_TYPE_P(ptr) == IS_ARRAY
) {
zval *tmp_ptr = ptr;
/* now find key in ptr */
zval *tmp_ptr = ptr;
/* now find key in ptr */
@@
-552,8
+559,12
@@
static void merge_param(HashTable *params, zval *zdata, zval **current_param, zv
static void push_param(HashTable *params, php_http_params_state_t *state, const php_http_params_opts_t *opts)
{
if (state->val.str) {
static void push_param(HashTable *params, php_http_params_state_t *state, const php_http_params_opts_t *opts)
{
if (state->val.str) {
- if (0 < (state->val.len = state->input.str - state->val.str)) {
+ if (!state->current.val) {
+ return;
+ } else if (0 < (state->val.len = state->input.str - state->val.str)) {
sanitize_value(opts->flags, state->val.str, state->val.len, state->current.val, state->rfc5987);
sanitize_value(opts->flags, state->val.str, state->val.len, state->current.val, state->rfc5987);
+ } else {
+ ZVAL_EMPTY_STRING(state->current.val);
}
state->rfc5987 = 0;
} else if (state->arg.str) {
}
state->rfc5987 = 0;
} else if (state->arg.str) {
@@
-635,7
+646,7
@@
static size_t check_sep(php_http_params_state_t *state, php_http_params_token_t
if (state->quotes || state->escape) {
return 0;
}
if (state->quotes || state->escape) {
return 0;
}
-
+
if (sep) while (*sep) {
if (check_str(state->input.str, state->input.len, (*sep)->str, (*sep)->len)) {
return (*sep)->len;
if (sep) while (*sep) {
if (check_str(state->input.str, state->input.len, (*sep)->str, (*sep)->len)) {
return (*sep)->len;
@@
-685,7
+696,7
@@
HashTable *php_http_params_parse(HashTable *params, const php_http_params_opts_t
} else {
state.escape = (*state.input.str == '\\');
}
} else {
state.escape = (*state.input.str == '\\');
}
-
+
if (!state.param.str) {
/* initialize */
skip_sep(0, &state, opts->param, opts->arg, opts->val);
if (!state.param.str) {
/* initialize */
skip_sep(0, &state, opts->param, opts->arg, opts->val);
@@
-739,7
+750,7
@@
HashTable *php_http_params_parse(HashTable *params, const php_http_params_opts_t
}
}
}
}
}
}
-
+
if (state.input.len) {
++state.input.str;
--state.input.len;
if (state.input.len) {
++state.input.str;
--state.input.len;
@@
-810,13
+821,14
@@
static inline void shift_rfc5988(php_http_buffer_t *buf, char *key_str, size_t k
static inline void shift_rfc5988_val(php_http_buffer_t *buf, zval *zv, const char *vss, size_t vsl, unsigned flags)
{
static inline void shift_rfc5988_val(php_http_buffer_t *buf, zval *zv, const char *vss, size_t vsl, unsigned flags)
{
- zend_string *zs = zval_get_string(zv);
-
- quote_string(&zs, 1);
- php_http_buffer_append(buf, vss, vsl);
- php_http_buffer_append(buf, zs->val, zs->len);
+ zend_string *str, *zs = zval_get_string(zv);
+ str = quote_string(zs, 1);
zend_string_release(zs);
zend_string_release(zs);
+
+ php_http_buffer_append(buf, vss, vsl);
+ php_http_buffer_append(buf, str->val, str->len);
+ zend_string_release(str);
}
static inline void shift_val(php_http_buffer_t *buf, zval *zvalue, const char *vss, size_t vsl, unsigned flags)
}
static inline void shift_val(php_http_buffer_t *buf, zval *zvalue, const char *vss, size_t vsl, unsigned flags)