2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2014, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
13 #include "php_http_api.h"
15 static php_http_params_token_t def_param_sep
= {",", 1}, *def_param_sep_ptr
[] = {&def_param_sep
, NULL
};
16 static php_http_params_token_t def_arg_sep
= {";", 1}, *def_arg_sep_ptr
[] = {&def_arg_sep
, NULL
};
17 static php_http_params_token_t def_val_sep
= {"=", 1}, *def_val_sep_ptr
[] = {&def_val_sep
, NULL
};
18 static php_http_params_opts_t def_opts
= {
24 PHP_HTTP_PARAMS_DEFAULT
27 php_http_params_opts_t
*php_http_params_opts_default_get(php_http_params_opts_t
*opts
)
30 opts
= emalloc(sizeof(*opts
));
33 memcpy(opts
, &def_opts
, sizeof(def_opts
));
38 typedef struct php_http_params_state
{
39 php_http_params_token_t input
;
40 php_http_params_token_t param
;
41 php_http_params_token_t arg
;
42 php_http_params_token_t val
;
51 } php_http_params_state_t
;
53 static inline void sanitize_escaped(zval
*zv TSRMLS_DC
)
55 if (Z_STRVAL_P(zv
)[0] == '"' && Z_STRVAL_P(zv
)[Z_STRLEN_P(zv
) - 1] == '"') {
56 size_t deq_len
= Z_STRLEN_P(zv
) - 2;
57 char *deq
= estrndup(Z_STRVAL_P(zv
) + 1, deq_len
);
60 ZVAL_STRINGL(zv
, deq
, deq_len
, 0);
63 php_stripcslashes(Z_STRVAL_P(zv
), &Z_STRLEN_P(zv
));
66 static inline void prepare_escaped(zval
*zv TSRMLS_DC
)
68 if (Z_TYPE_P(zv
) == IS_STRING
) {
69 int len
= Z_STRLEN_P(zv
);
71 Z_STRVAL_P(zv
) = php_addcslashes(Z_STRVAL_P(zv
), Z_STRLEN_P(zv
), &Z_STRLEN_P(zv
), 1,
72 ZEND_STRL("\0..\37\173\\\"") TSRMLS_CC
);
74 if (len
!= Z_STRLEN_P(zv
) || strpbrk(Z_STRVAL_P(zv
), "()<>@,;:\"[]?={} ")) {
76 int len
= Z_STRLEN_P(zv
) + 2;
77 char *str
= emalloc(len
+ 1);
80 memcpy(&str
[1], Z_STRVAL_P(zv
), Z_STRLEN_P(zv
));
85 ZVAL_STRINGL(zv
, str
, len
, 0);
89 ZVAL_EMPTY_STRING(zv
);
93 static inline void sanitize_urlencoded(zval
*zv TSRMLS_DC
)
95 Z_STRLEN_P(zv
) = php_raw_url_decode(Z_STRVAL_P(zv
), Z_STRLEN_P(zv
));
98 static inline void prepare_urlencoded(zval
*zv TSRMLS_DC
)
101 char *str
= php_raw_url_encode(Z_STRVAL_P(zv
), Z_STRLEN_P(zv
), &len
);
104 ZVAL_STRINGL(zv
, str
, len
, 0);
107 static void sanitize_dimension(zval
*zv TSRMLS_DC
)
109 zval
*arr
= NULL
, *tmp
= NULL
, **cur
= NULL
;
110 char *var
= NULL
, *ptr
= Z_STRVAL_P(zv
), *end
= Z_STRVAL_P(zv
) + Z_STRLEN_P(zv
);
124 if (++level
> PG(max_input_nesting_level
)) {
126 php_error_docref(NULL TSRMLS_CC
, E_WARNING
, "Max input nesting level of %ld exceeded", (long) PG(max_input_nesting_level
));
129 if (ptr
- var
== 0) {
139 convert_to_array(*cur
);
144 zend_symtable_update(Z_ARRVAL_PP(cur
), var
, ptr
- var
+ 1, (void *) &tmp
, sizeof(zval
*), (void *) &cur
);
147 zend_hash_next_index_insert(Z_ARRVAL_PP(cur
), (void *) &tmp
, sizeof(zval
*), (void *) &cur
);
157 if (zend_hash_num_elements(Z_ARRVAL_P(arr
))) {
159 #if PHP_VERSION_ID >= 50400
160 ZVAL_COPY_VALUE(zv
, arr
);
162 zv
->value
= arr
->value
;
163 Z_TYPE_P(zv
) = Z_TYPE_P(arr
);
171 static inline void shift_key(php_http_buffer_t
*buf
, char *key_str
, size_t key_len
, const char *ass
, size_t asl
, unsigned flags TSRMLS_DC
);
172 static inline void shift_val(php_http_buffer_t
*buf
, zval
*zvalue
, const char *vss
, size_t vsl
, unsigned flags TSRMLS_DC
);
174 static void prepare_dimension(php_http_buffer_t
*buf
, php_http_buffer_t
*keybuf
, zval
*zvalue
, const char *pss
, size_t psl
, const char *vss
, size_t vsl
, unsigned flags TSRMLS_DC
)
176 HashTable
*ht
= HASH_OF(zvalue
);
178 php_http_array_hashkey_t key
= php_http_array_hashkey_init(0);
180 php_http_buffer_t prefix
;
182 if (!ht
->nApplyCount
++) {
183 php_http_buffer_init(&prefix
);
184 php_http_buffer_append(&prefix
, keybuf
->data
, keybuf
->used
);
186 FOREACH_HASH_KEYVAL(pos
, ht
, key
, val
) {
187 if (key
.type
== HASH_KEY_IS_STRING
&& !*key
.str
) {
188 /* only public properties */
192 php_http_buffer_appends(&prefix
, "[");
193 if (key
.type
== HASH_KEY_IS_STRING
) {
194 php_http_buffer_append(&prefix
, key
.str
, key
.len
- 1);
196 php_http_buffer_appendf(&prefix
, "%lu", key
.num
);
198 php_http_buffer_appends(&prefix
, "]");
200 if (Z_TYPE_PP(val
) == IS_ARRAY
|| Z_TYPE_PP(val
) == IS_OBJECT
) {
201 prepare_dimension(buf
, &prefix
, *val
, pss
, psl
, vss
, vsl
, flags TSRMLS_CC
);
203 zval
*cpy
= php_http_ztyp(IS_STRING
, *val
);
205 shift_key(buf
, prefix
.data
, prefix
.used
, pss
, psl
, flags TSRMLS_CC
);
206 shift_val(buf
, cpy
, vss
, vsl
, flags TSRMLS_CC
);
210 php_http_buffer_cut(&prefix
, keybuf
->used
, prefix
.used
- keybuf
->used
);
212 php_http_buffer_dtor(&prefix
);
217 static inline void sanitize_key(unsigned flags
, char *str
, size_t len
, zval
*zv
, zend_bool
*rfc5987 TSRMLS_DC
)
222 php_trim(str
, len
, NULL
, 0, zv
, 3 TSRMLS_CC
);
224 if (flags
& PHP_HTTP_PARAMS_ESCAPED
) {
225 sanitize_escaped(zv TSRMLS_CC
);
228 if (!Z_STRLEN_P(zv
)) {
232 eos
= &Z_STRVAL_P(zv
)[Z_STRLEN_P(zv
)-1];
239 if (flags
& PHP_HTTP_PARAMS_URLENCODED
) {
240 sanitize_urlencoded(zv TSRMLS_CC
);
243 if (flags
& PHP_HTTP_PARAMS_DIMENSION
) {
244 sanitize_dimension(zv TSRMLS_CC
);
248 static inline void sanitize_rfc5987(zval
*zv
, char **language
, zend_bool
*latin1 TSRMLS_DC
)
253 * iso-8850-1'de'bl%f6der%20schei%df%21
254 * utf-8'de-DE'bl%c3%b6der%20schei%c3%9f%21
257 switch (Z_STRVAL_P(zv
)[0]) {
260 if (!strncasecmp(Z_STRVAL_P(zv
), "iso-8859-1", lenof("iso-8859-1"))) {
262 ptr
= Z_STRVAL_P(zv
) + lenof("iso-8859-1");
268 if (!strncasecmp(Z_STRVAL_P(zv
), "utf-8", lenof("utf-8"))) {
270 ptr
= Z_STRVAL_P(zv
) + lenof("utf-8");
278 /* extract language */
280 for (*language
= ++ptr
; *ptr
&& *ptr
!= '\''; ++ptr
);
285 *language
= estrndup(*language
, ptr
- *language
);
288 ptr
= estrdup(++ptr
);
290 ZVAL_STRING(zv
, ptr
, 0);
294 static inline void sanitize_rfc5988(char *str
, size_t len
, zval
*zv TSRMLS_DC
)
297 php_trim(str
, len
, " ><", 3, zv
, 3 TSRMLS_CC
);
300 static void utf8encode(zval
*zv
)
303 unsigned char *ptr
= (unsigned char *) Z_STRVAL_P(zv
);
306 if (*ptr
++ >= 0x80) {
312 ptr
= safe_emalloc(1, len
, 1);
313 for (len
= 0, pos
= 0; len
<= Z_STRLEN_P(zv
); ++len
, ++pos
) {
314 ptr
[pos
] = Z_STRVAL_P(zv
)[len
];
315 if ((ptr
[pos
]) >= 0x80) {
316 ptr
[pos
+ 1] = 0x80 | (ptr
[pos
] & 0x3f);
317 ptr
[pos
] = 0xc0 | ((ptr
[pos
] >> 6) & 0x1f);
322 ZVAL_STRINGL(zv
, (char *) ptr
, pos
-1, 0);
325 static inline void sanitize_value(unsigned flags
, char *str
, size_t len
, zval
*zv
, zend_bool rfc5987 TSRMLS_DC
)
327 char *language
= NULL
;
328 zend_bool latin1
= 0;
331 php_trim(str
, len
, NULL
, 0, zv
, 3 TSRMLS_CC
);
334 sanitize_rfc5987(zv
, &language
, &latin1 TSRMLS_CC
);
337 if (flags
& PHP_HTTP_PARAMS_ESCAPED
) {
338 sanitize_escaped(zv TSRMLS_CC
);
341 if ((flags
& PHP_HTTP_PARAMS_URLENCODED
) || (rfc5987
&& language
)) {
342 sanitize_urlencoded(zv TSRMLS_CC
);
345 if (rfc5987
&& language
) {
353 ZVAL_COPY_VALUE(tmp
, zv
);
355 add_assoc_zval(zv
, language
, tmp
);
360 static inline void prepare_key(unsigned flags
, char *old_key
, size_t old_len
, char **new_key
, size_t *new_len TSRMLS_DC
)
365 ZVAL_STRINGL(&zv
, old_key
, old_len
, 1);
367 if (flags
& PHP_HTTP_PARAMS_URLENCODED
) {
368 prepare_urlencoded(&zv TSRMLS_CC
);
371 if (flags
& PHP_HTTP_PARAMS_ESCAPED
) {
372 prepare_escaped(&zv TSRMLS_CC
);
375 *new_key
= Z_STRVAL(zv
);
376 *new_len
= Z_STRLEN(zv
);
379 static inline void prepare_value(unsigned flags
, zval
*zv TSRMLS_DC
)
381 if (flags
& PHP_HTTP_PARAMS_URLENCODED
) {
382 prepare_urlencoded(zv TSRMLS_CC
);
385 if (flags
& PHP_HTTP_PARAMS_ESCAPED
) {
386 prepare_escaped(zv TSRMLS_CC
);
390 static void merge_param(HashTable
*params
, zval
*zdata
, zval
***current_param
, zval
***current_args TSRMLS_DC
)
392 zval
**ptr
, **zdata_ptr
;
393 php_http_array_hashkey_t hkey
= php_http_array_hashkey_init(0);
398 INIT_PZVAL_ARRAY(&tmp
, params
);
399 fprintf(stderr
, "params = ");
400 zend_print_zval_r(&tmp
, 1 TSRMLS_CC
);
401 fprintf(stderr
, "\n");
405 hkey
.type
= zend_hash_get_current_key_ex(Z_ARRVAL_P(zdata
), &hkey
.str
, &hkey
.len
, &hkey
.num
, hkey
.dup
, NULL
);
407 if ((hkey
.type
== HASH_KEY_IS_STRING
&& !zend_hash_exists(params
, hkey
.str
, hkey
.len
))
408 || (hkey
.type
== HASH_KEY_IS_LONG
&& !zend_hash_index_exists(params
, hkey
.num
))
410 zval
*tmp
, *arg
, **args
;
412 /* create the entry if it doesn't exist */
413 zend_hash_get_current_data(Z_ARRVAL_P(zdata
), (void *) &ptr
);
417 add_assoc_zval_ex(tmp
, ZEND_STRS("value"), *ptr
);
421 zend_hash_update(Z_ARRVAL_P(tmp
), "arguments", sizeof("arguments"), (void *) &arg
, sizeof(zval
*), (void *) &args
);
422 *current_args
= args
;
424 if (hkey
.type
== HASH_KEY_IS_STRING
) {
425 zend_hash_update(params
, hkey
.str
, hkey
.len
, (void *) &tmp
, sizeof(zval
*), (void *) &ptr
);
427 zend_hash_index_update(params
, hkey
.num
, (void *) &tmp
, sizeof(zval
*), (void *) &ptr
);
431 if (hkey
.type
== HASH_KEY_IS_STRING
) {
432 zend_hash_find(params
, hkey
.str
, hkey
.len
, (void *) &ptr
);
434 zend_hash_index_find(params
, hkey
.num
, (void *) &ptr
);
439 if (Z_TYPE_PP(ptr
) == IS_ARRAY
440 && SUCCESS
== zend_hash_find(Z_ARRVAL_PP(ptr
), "value", sizeof("value"), (void *) &ptr
)
441 && SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_PP(zdata_ptr
), (void *) &zdata_ptr
)
444 * params = [arr => [value => [0 => 1]]]
446 * zdata = [arr => [0 => NULL]]
451 while (Z_TYPE_PP(zdata_ptr
) == IS_ARRAY
452 && SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_PP(zdata_ptr
), (void *) &test_ptr
)
454 if (Z_TYPE_PP(test_ptr
) == IS_ARRAY
) {
456 /* now find key in ptr */
457 if (HASH_KEY_IS_STRING
== zend_hash_get_current_key_ex(Z_ARRVAL_PP(zdata_ptr
), &hkey
.str
, &hkey
.len
, &hkey
.num
, hkey
.dup
, NULL
)) {
458 if (SUCCESS
== zend_hash_find(Z_ARRVAL_PP(ptr
), hkey
.str
, hkey
.len
, (void *) &ptr
)) {
459 zdata_ptr
= test_ptr
;
461 Z_ADDREF_PP(test_ptr
);
462 zend_hash_update(Z_ARRVAL_PP(ptr
), hkey
.str
, hkey
.len
, (void *) test_ptr
, sizeof(zval
*), (void *) &ptr
);
466 if (SUCCESS
== zend_hash_index_find(Z_ARRVAL_PP(ptr
), hkey
.num
, (void *) &ptr
)) {
467 zdata_ptr
= test_ptr
;
468 } else if (hkey
.num
) {
469 Z_ADDREF_PP(test_ptr
);
470 zend_hash_index_update(Z_ARRVAL_PP(ptr
), hkey
.num
, (void *) test_ptr
, sizeof(zval
*), (void *) &ptr
);
473 Z_ADDREF_PP(test_ptr
);
474 zend_hash_next_index_insert(Z_ARRVAL_PP(ptr
), (void *) test_ptr
, sizeof(zval
*), (void *) &ptr
);
479 /* this is the leaf */
480 Z_ADDREF_PP(test_ptr
);
481 if (Z_TYPE_PP(ptr
) != IS_ARRAY
) {
485 if (HASH_KEY_IS_STRING
== zend_hash_get_current_key_ex(Z_ARRVAL_PP(zdata_ptr
), &hkey
.str
, &hkey
.len
, &hkey
.num
, hkey
.dup
, NULL
)) {
486 zend_hash_update(Z_ARRVAL_PP(ptr
), hkey
.str
, hkey
.len
, (void *) test_ptr
, sizeof(zval
*), (void *) &ptr
);
487 } else if (hkey
.num
) {
488 zend_hash_index_update(Z_ARRVAL_PP(ptr
), hkey
.num
, (void *) test_ptr
, sizeof(zval
*), (void *) &ptr
);
490 zend_hash_next_index_insert(Z_ARRVAL_PP(ptr
), (void *) test_ptr
, sizeof(zval
*), (void *) &ptr
);
500 while (Z_TYPE_PP(ptr
) == IS_ARRAY
&& SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_PP(ptr
), (void *) &ptr
));
501 *current_param
= ptr
;
504 static void push_param(HashTable
*params
, php_http_params_state_t
*state
, const php_http_params_opts_t
*opts TSRMLS_DC
)
506 if (state
->val
.str
) {
507 if (0 < (state
->val
.len
= state
->input
.str
- state
->val
.str
)) {
508 sanitize_value(opts
->flags
, state
->val
.str
, state
->val
.len
, *(state
->current
.val
), state
->rfc5987 TSRMLS_CC
);
511 } else if (state
->arg
.str
) {
512 if (0 < (state
->arg
.len
= state
->input
.str
- state
->arg
.str
)) {
514 zend_bool rfc5987
= 0;
518 sanitize_key(opts
->flags
, state
->arg
.str
, state
->arg
.len
, &key
, &rfc5987 TSRMLS_CC
);
519 state
->rfc5987
= rfc5987
;
520 if (Z_TYPE(key
) == IS_STRING
&& Z_STRLEN(key
)) {
527 if (SUCCESS
== zend_hash_find(Z_ARRVAL_PP(state
->current
.args
), ZEND_STRS("*rfc5987*"), (void *) &rfc
)) {
528 zend_symtable_update(Z_ARRVAL_PP(rfc
), Z_STRVAL(key
), Z_STRLEN(key
) + 1, (void *) &val
, sizeof(zval
*), (void *) &state
->current
.val
);
533 array_init_size(tmp
, 1);
534 zend_symtable_update(Z_ARRVAL_P(tmp
), Z_STRVAL(key
), Z_STRLEN(key
) + 1, (void *) &val
, sizeof(zval
*), (void *) &state
->current
.val
);
535 zend_symtable_update(Z_ARRVAL_PP(state
->current
.args
), ZEND_STRS("*rfc5987*"), (void *) &tmp
, sizeof(zval
*), NULL
);
538 zend_symtable_update(Z_ARRVAL_PP(state
->current
.args
), Z_STRVAL(key
), Z_STRLEN(key
) + 1, (void *) &val
, sizeof(zval
*), (void *) &state
->current
.val
);
543 } else if (state
->param
.str
) {
544 if (0 < (state
->param
.len
= state
->input
.str
- state
->param
.str
)) {
545 zval
*prm
, *arg
, *val
, *key
;
546 zend_bool rfc5987
= 0;
550 if (opts
->flags
& PHP_HTTP_PARAMS_RFC5988
) {
551 sanitize_rfc5988(state
->param
.str
, state
->param
.len
, key TSRMLS_CC
);
553 sanitize_key(opts
->flags
, state
->param
.str
, state
->param
.len
, key
, &rfc5987 TSRMLS_CC
);
554 state
->rfc5987
= rfc5987
;
556 if (Z_TYPE_P(key
) != IS_STRING
) {
557 merge_param(params
, key
, &state
->current
.val
, &state
->current
.args TSRMLS_CC
);
558 } else if (Z_STRLEN_P(key
)) {
560 array_init_size(prm
, 2);
564 ZVAL_COPY_VALUE(val
, opts
->defval
);
569 if (rfc5987
&& (opts
->flags
& PHP_HTTP_PARAMS_RFC5987
)) {
570 zend_hash_update(Z_ARRVAL_P(prm
), "*rfc5987*", sizeof("*rfc5987*"), (void *) &val
, sizeof(zval
*), (void *) &state
->current
.val
);
572 zend_hash_update(Z_ARRVAL_P(prm
), "value", sizeof("value"), (void *) &val
, sizeof(zval
*), (void *) &state
->current
.val
);
576 array_init_size(arg
, 3);
577 zend_hash_update(Z_ARRVAL_P(prm
), "arguments", sizeof("arguments"), (void *) &arg
, sizeof(zval
*), (void *) &state
->current
.args
);
579 zend_symtable_update(params
, Z_STRVAL_P(key
), Z_STRLEN_P(key
) + 1, (void *) &prm
, sizeof(zval
*), (void *) &state
->current
.param
);
586 static inline zend_bool
check_str(const char *chk_str
, size_t chk_len
, const char *sep_str
, size_t sep_len
) {
587 return 0 < sep_len
&& chk_len
>= sep_len
&& *chk_str
== *sep_str
&& !memcmp(chk_str
+ 1, sep_str
+ 1, sep_len
- 1);
590 static size_t check_sep(php_http_params_state_t
*state
, php_http_params_token_t
**separators
)
592 php_http_params_token_t
**sep
= separators
;
594 if (state
->quotes
|| state
->escape
) {
598 if (sep
) while (*sep
) {
599 if (check_str(state
->input
.str
, state
->input
.len
, (*sep
)->str
, (*sep
)->len
)) {
607 static void skip_sep(size_t skip
, php_http_params_state_t
*state
, php_http_params_token_t
**param
, php_http_params_token_t
**arg
, php_http_params_token_t
**val TSRMLS_DC
)
611 state
->input
.str
+= skip
;
612 state
->input
.len
-= skip
;
614 while ( (param
&& (sep_len
= check_sep(state
, param
)))
615 || (arg
&& (sep_len
= check_sep(state
, arg
)))
616 || (val
&& (sep_len
= check_sep(state
, val
)))
618 state
->input
.str
+= sep_len
;
619 state
->input
.len
-= sep_len
;
623 HashTable
*php_http_params_parse(HashTable
*params
, const php_http_params_opts_t
*opts TSRMLS_DC
)
625 php_http_params_state_t state
= {{NULL
,0}, {NULL
,0}, {NULL
,0}, {NULL
,0}, {NULL
,NULL
,NULL
}, 0, 0};
627 state
.input
.str
= opts
->input
.str
;
628 state
.input
.len
= opts
->input
.len
;
631 ALLOC_HASHTABLE(params
);
632 ZEND_INIT_SYMTABLE(params
);
635 while (state
.input
.len
) {
636 if ((opts
->flags
& PHP_HTTP_PARAMS_RFC5988
) && !state
.arg
.str
) {
637 if (*state
.input
.str
== '<') {
639 } else if (*state
.input
.str
== '>') {
642 } else if (*state
.input
.str
== '"' && !state
.escape
) {
643 state
.quotes
= !state
.quotes
;
645 state
.escape
= (*state
.input
.str
== '\\');
648 if (!state
.param
.str
) {
650 skip_sep(0, &state
, opts
->param
, opts
->arg
, opts
->val TSRMLS_CC
);
651 state
.param
.str
= state
.input
.str
;
654 /* are we at a param separator? */
655 if (0 < (sep_len
= check_sep(&state
, opts
->param
))) {
656 push_param(params
, &state
, opts TSRMLS_CC
);
658 skip_sep(sep_len
, &state
, opts
->param
, opts
->arg
, opts
->val TSRMLS_CC
);
660 /* start off with a new param */
661 state
.param
.str
= state
.input
.str
;
663 state
.arg
.str
= NULL
;
665 state
.val
.str
= NULL
;
671 /* are we at an arg separator? */
672 if (0 < (sep_len
= check_sep(&state
, opts
->arg
))) {
673 push_param(params
, &state
, opts TSRMLS_CC
);
675 skip_sep(sep_len
, &state
, NULL
, opts
->arg
, opts
->val TSRMLS_CC
);
677 /* continue with a new arg */
678 state
.arg
.str
= state
.input
.str
;
680 state
.val
.str
= NULL
;
686 /* are we at a val separator? */
687 if (0 < (sep_len
= check_sep(&state
, opts
->val
))) {
688 /* only handle separator if we're not already reading in a val */
689 if (!state
.val
.str
) {
690 push_param(params
, &state
, opts TSRMLS_CC
);
692 skip_sep(sep_len
, &state
, NULL
, NULL
, opts
->val TSRMLS_CC
);
694 state
.val
.str
= state
.input
.str
;
702 if (state
.input
.len
) {
708 push_param(params
, &state
, opts TSRMLS_CC
);
713 static inline void shift_key(php_http_buffer_t
*buf
, char *key_str
, size_t key_len
, const char *ass
, size_t asl
, unsigned flags TSRMLS_DC
)
719 php_http_buffer_append(buf
, ass
, asl
);
722 prepare_key(flags
, key_str
, key_len
, &str
, &len TSRMLS_CC
);
723 php_http_buffer_append(buf
, str
, len
);
727 static inline void shift_rfc5987(php_http_buffer_t
*buf
, zval
*zvalue
, const char *vss
, size_t vsl
, unsigned flags TSRMLS_DC
)
729 HashTable
*ht
= HASH_OF(zvalue
);
731 php_http_array_hashkey_t key
= php_http_array_hashkey_init(0);
733 if (SUCCESS
== zend_hash_get_current_data(ht
, (void *) &zdata
)
734 && HASH_KEY_NON_EXISTENT
!= (key
.type
= zend_hash_get_current_key_ex(ht
, &key
.str
, &key
.len
, &key
.num
, key
.dup
, NULL
))
736 php_http_array_hashkey_stringify(&key
);
737 php_http_buffer_appendf(buf
, "*%.*sutf-8'%.*s'",
738 (int) (vsl
> INT_MAX
? INT_MAX
: vsl
), vss
,
739 (int) (key
.len
> INT_MAX
? INT_MAX
: key
.len
), key
.str
);
740 php_http_array_hashkey_stringfree(&key
);
742 tmp
= php_http_zsep(1, IS_STRING
, *zdata
);
743 prepare_value(flags
| PHP_HTTP_PARAMS_URLENCODED
, tmp TSRMLS_CC
);
744 php_http_buffer_append(buf
, Z_STRVAL_P(tmp
), Z_STRLEN_P(tmp
));
749 static inline void shift_rfc5988(php_http_buffer_t
*buf
, char *key_str
, size_t key_len
, const char *ass
, size_t asl
, unsigned flags TSRMLS_DC
)
755 php_http_buffer_append(buf
, ass
, asl
);
758 prepare_key(flags
, key_str
, key_len
, &str
, &len TSRMLS_CC
);
759 php_http_buffer_appends(buf
, "<");
760 php_http_buffer_append(buf
, str
, len
);
761 php_http_buffer_appends(buf
, ">");
765 static inline void shift_val(php_http_buffer_t
*buf
, zval
*zvalue
, const char *vss
, size_t vsl
, unsigned flags TSRMLS_DC
)
767 if (Z_TYPE_P(zvalue
) != IS_BOOL
) {
768 zval
*tmp
= php_http_zsep(1, IS_STRING
, zvalue
);
770 prepare_value(flags
, tmp TSRMLS_CC
);
771 php_http_buffer_append(buf
, vss
, vsl
);
772 php_http_buffer_append(buf
, Z_STRVAL_P(tmp
), Z_STRLEN_P(tmp
));
775 } else if (!Z_BVAL_P(zvalue
)) {
776 php_http_buffer_append(buf
, vss
, vsl
);
777 php_http_buffer_appends(buf
, "0");
781 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
)
783 if (Z_TYPE_P(zvalue
) == IS_ARRAY
|| Z_TYPE_P(zvalue
) == IS_OBJECT
) {
785 php_http_array_hashkey_t key
= php_http_array_hashkey_init(0);
787 zend_bool rfc5987
= !strcmp(key_str
, "*rfc5987*");
790 shift_key(buf
, key_str
, key_len
, ass
, asl
, flags TSRMLS_CC
);
792 FOREACH_KEYVAL(pos
, zvalue
, key
, val
) {
793 /* did you mean recursion? */
794 php_http_array_hashkey_stringify(&key
);
795 if (rfc5987
&& (Z_TYPE_PP(val
) == IS_ARRAY
|| Z_TYPE_PP(val
) == IS_OBJECT
)) {
796 shift_key(buf
, key
.str
, key
.len
-1, ass
, asl
, flags TSRMLS_CC
);
797 shift_rfc5987(buf
, *val
, vss
, vsl
, flags TSRMLS_CC
);
799 shift_arg(buf
, key
.str
, key
.len
-1, *val
, ass
, asl
, vss
, vsl
, flags TSRMLS_CC
);
801 php_http_array_hashkey_stringfree(&key
);
804 shift_key(buf
, key_str
, key_len
, ass
, asl
, flags TSRMLS_CC
);
805 shift_val(buf
, zvalue
, vss
, vsl
, flags TSRMLS_CC
);
809 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
)
811 if (Z_TYPE_P(zvalue
) == IS_ARRAY
|| Z_TYPE_P(zvalue
) == IS_OBJECT
) {
812 /* treat as arguments, unless we care for dimensions or rfc5987 */
813 if (flags
& PHP_HTTP_PARAMS_DIMENSION
) {
814 php_http_buffer_t
*keybuf
= php_http_buffer_from_string(key_str
, key_len
);
815 prepare_dimension(buf
, keybuf
, zvalue
, pss
, psl
, vss
, vsl
, flags TSRMLS_CC
);
816 php_http_buffer_free(&keybuf
);
817 } else if (rfc5987
) {
818 shift_key(buf
, key_str
, key_len
, pss
, psl
, flags TSRMLS_CC
);
819 shift_rfc5987(buf
, zvalue
, vss
, vsl
, flags TSRMLS_CC
);
821 shift_arg(buf
, key_str
, key_len
, zvalue
, ass
, asl
, vss
, vsl
, flags TSRMLS_CC
);
824 if (flags
& PHP_HTTP_PARAMS_RFC5988
) {
825 shift_rfc5988(buf
, key_str
, key_len
, pss
, psl
, flags TSRMLS_CC
);
827 shift_key(buf
, key_str
, key_len
, pss
, psl
, flags TSRMLS_CC
);
829 shift_val(buf
, zvalue
, vss
, vsl
, flags TSRMLS_CC
);
833 php_http_buffer_t
*php_http_params_to_string(php_http_buffer_t
*buf
, HashTable
*params
, const char *pss
, size_t psl
, const char *ass
, size_t asl
, const char *vss
, size_t vsl
, unsigned flags TSRMLS_DC
)
836 HashPosition pos
, pos1
;
837 php_http_array_hashkey_t key
= php_http_array_hashkey_init(0), key1
= php_http_array_hashkey_init(0);
838 zend_bool rfc5987
= 0;
841 buf
= php_http_buffer_init(NULL
);
844 FOREACH_HASH_KEYVAL(pos
, params
, key
, zparam
) {
845 zval
**zvalue
, **zargs
;
847 if (Z_TYPE_PP(zparam
) != IS_ARRAY
) {
850 if (SUCCESS
!= zend_hash_find(Z_ARRVAL_PP(zparam
), ZEND_STRS("value"), (void *) &zvalue
)) {
851 if (SUCCESS
!= zend_hash_find(Z_ARRVAL_PP(zparam
), ZEND_STRS("*rfc5987*"), (void *) &zvalue
)) {
859 php_http_array_hashkey_stringify(&key
);
860 shift_param(buf
, key
.str
, key
.len
- 1, *zvalue
, pss
, psl
, ass
, asl
, vss
, vsl
, flags
, rfc5987 TSRMLS_CC
);
861 php_http_array_hashkey_stringfree(&key
);
863 if (Z_TYPE_PP(zparam
) == IS_ARRAY
&& SUCCESS
!= zend_hash_find(Z_ARRVAL_PP(zparam
), ZEND_STRS("arguments"), (void *) &zvalue
)) {
864 if (zvalue
== zparam
) {
870 if (Z_TYPE_PP(zvalue
) == IS_ARRAY
) {
871 FOREACH_KEYVAL(pos1
, *zvalue
, key1
, zargs
) {
872 if (zvalue
== zparam
&& key1
.type
== HASH_KEY_IS_STRING
&& !strcmp(key1
.str
, "value")) {
876 php_http_array_hashkey_stringify(&key1
);
877 shift_arg(buf
, key1
.str
, key1
.len
- 1, *zargs
, ass
, asl
, vss
, vsl
, flags TSRMLS_CC
);
878 php_http_array_hashkey_stringfree(&key1
);
883 php_http_buffer_shrink(buf
);
884 php_http_buffer_fix(buf
);
889 php_http_params_token_t
**php_http_params_separator_init(zval
*zv TSRMLS_DC
)
893 php_http_params_token_t
**ret
, **tmp
;
899 zv
= php_http_ztyp(IS_ARRAY
, zv
);
900 ret
= ecalloc(zend_hash_num_elements(Z_ARRVAL_P(zv
)) + 1, sizeof(*ret
));
903 FOREACH_VAL(pos
, zv
, sep
) {
904 zval
*zt
= php_http_ztyp(IS_STRING
, *sep
);
906 if (Z_STRLEN_P(zt
)) {
907 *tmp
= emalloc(sizeof(**tmp
));
908 (*tmp
)->str
= estrndup(Z_STRVAL_P(zt
), (*tmp
)->len
= Z_STRLEN_P(zt
));
919 void php_http_params_separator_free(php_http_params_token_t
**separator
)
921 php_http_params_token_t
**sep
= separator
;
924 PTR_FREE((*sep
)->str
);
932 ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams___construct
, 0, 0, 0)
933 ZEND_ARG_INFO(0, params
)
934 ZEND_ARG_INFO(0, param_sep
)
935 ZEND_ARG_INFO(0, arg_sep
)
936 ZEND_ARG_INFO(0, val_sep
)
937 ZEND_ARG_INFO(0, flags
)
939 PHP_METHOD(HttpParams
, __construct
)
941 zval
*zcopy
, *zparams
= NULL
, *param_sep
= NULL
, *arg_sep
= NULL
, *val_sep
= NULL
;
942 long flags
= PHP_HTTP_PARAMS_DEFAULT
;
943 zend_error_handling zeh
;
945 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|z!/z/z/z/l", &zparams
, ¶m_sep
, &arg_sep
, &val_sep
, &flags
), invalid_arg
, return);
947 zend_replace_error_handling(EH_THROW
, php_http_exception_runtime_class_entry
, &zeh TSRMLS_CC
);
949 switch (ZEND_NUM_ARGS()) {
951 zend_update_property_long(php_http_params_class_entry
, getThis(), ZEND_STRL("flags"), flags TSRMLS_CC
);
954 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("val_sep"), val_sep TSRMLS_CC
);
957 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("arg_sep"), arg_sep TSRMLS_CC
);
960 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("param_sep"), param_sep TSRMLS_CC
);
965 switch (Z_TYPE_P(zparams
)) {
968 zcopy
= php_http_zsep(1, IS_ARRAY
, zparams
);
969 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), zcopy TSRMLS_CC
);
970 zval_ptr_dtor(&zcopy
);
973 zcopy
= php_http_ztyp(IS_STRING
, zparams
);
974 if (Z_STRLEN_P(zcopy
)) {
975 php_http_params_opts_t opts
= {
976 {Z_STRVAL_P(zcopy
), Z_STRLEN_P(zcopy
)},
977 php_http_params_separator_init(zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("param_sep"), 0 TSRMLS_CC
) TSRMLS_CC
),
978 php_http_params_separator_init(zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("arg_sep"), 0 TSRMLS_CC
) TSRMLS_CC
),
979 php_http_params_separator_init(zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("val_sep"), 0 TSRMLS_CC
) TSRMLS_CC
),
983 MAKE_STD_ZVAL(zparams
);
985 php_http_params_parse(Z_ARRVAL_P(zparams
), &opts TSRMLS_CC
);
986 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), zparams TSRMLS_CC
);
987 zval_ptr_dtor(&zparams
);
989 php_http_params_separator_free(opts
.param
);
990 php_http_params_separator_free(opts
.arg
);
991 php_http_params_separator_free(opts
.val
);
993 zval_ptr_dtor(&zcopy
);
997 MAKE_STD_ZVAL(zparams
);
999 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), zparams TSRMLS_CC
);
1000 zval_ptr_dtor(&zparams
);
1003 zend_restore_error_handling(&zeh TSRMLS_CC
);
1006 ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_toArray
, 0, 0, 0)
1007 ZEND_END_ARG_INFO();
1008 PHP_METHOD(HttpParams
, toArray
)
1012 if (SUCCESS
!= zend_parse_parameters_none()) {
1015 zparams
= zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), 0 TSRMLS_CC
);
1016 RETURN_ZVAL(zparams
, 1, 0);
1019 ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_toString
, 0, 0, 0)
1020 ZEND_END_ARG_INFO();
1021 PHP_METHOD(HttpParams
, toString
)
1023 zval
**tmp
, *zparams
, *zpsep
, *zasep
, *zvsep
, *zflags
;
1024 php_http_buffer_t buf
;
1026 zparams
= php_http_zsep(1, IS_ARRAY
, zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), 0 TSRMLS_CC
));
1027 zflags
= php_http_ztyp(IS_LONG
, zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("flags"), 0 TSRMLS_CC
));
1029 zpsep
= zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("param_sep"), 0 TSRMLS_CC
);
1030 if (Z_TYPE_P(zpsep
) == IS_ARRAY
&& SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_P(zpsep
), (void *) &tmp
)) {
1031 zpsep
= php_http_ztyp(IS_STRING
, *tmp
);
1033 zpsep
= php_http_ztyp(IS_STRING
, zpsep
);
1035 zasep
= zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("arg_sep"), 0 TSRMLS_CC
);
1036 if (Z_TYPE_P(zasep
) == IS_ARRAY
&& SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_P(zasep
), (void *) &tmp
)) {
1037 zasep
= php_http_ztyp(IS_STRING
, *tmp
);
1039 zasep
= php_http_ztyp(IS_STRING
, zasep
);
1041 zvsep
= zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("val_sep"), 0 TSRMLS_CC
);
1042 if (Z_TYPE_P(zvsep
) == IS_ARRAY
&& SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_P(zvsep
), (void *) &tmp
)) {
1043 zvsep
= php_http_ztyp(IS_STRING
, *tmp
);
1045 zvsep
= php_http_ztyp(IS_STRING
, zvsep
);
1048 php_http_buffer_init(&buf
);
1049 php_http_params_to_string(&buf
, Z_ARRVAL_P(zparams
), Z_STRVAL_P(zpsep
), Z_STRLEN_P(zpsep
), Z_STRVAL_P(zasep
), Z_STRLEN_P(zasep
), Z_STRVAL_P(zvsep
), Z_STRLEN_P(zvsep
), Z_LVAL_P(zflags
) TSRMLS_CC
);
1051 zval_ptr_dtor(&zparams
);
1052 zval_ptr_dtor(&zpsep
);
1053 zval_ptr_dtor(&zasep
);
1054 zval_ptr_dtor(&zvsep
);
1055 zval_ptr_dtor(&zflags
);
1057 RETVAL_PHP_HTTP_BUFFER_VAL(&buf
);
1060 ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_offsetExists
, 0, 0, 1)
1061 ZEND_ARG_INFO(0, name
)
1062 ZEND_END_ARG_INFO();
1063 PHP_METHOD(HttpParams
, offsetExists
)
1067 zval
**zparam
, *zparams
;
1069 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &name_str
, &name_len
)) {
1073 zparams
= php_http_ztyp(IS_ARRAY
, zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), 0 TSRMLS_CC
));
1075 if (SUCCESS
== zend_symtable_find(Z_ARRVAL_P(zparams
), name_str
, name_len
+ 1, (void *) &zparam
)) {
1076 RETVAL_BOOL(Z_TYPE_PP(zparam
) != IS_NULL
);
1080 zval_ptr_dtor(&zparams
);
1083 ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_offsetGet
, 0, 0, 1)
1084 ZEND_ARG_INFO(0, name
)
1085 ZEND_END_ARG_INFO();
1086 PHP_METHOD(HttpParams
, offsetGet
)
1090 zval
**zparam
, *zparams
;
1092 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &name_str
, &name_len
)) {
1096 zparams
= php_http_ztyp(IS_ARRAY
, zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), 0 TSRMLS_CC
));
1098 if (SUCCESS
== zend_symtable_find(Z_ARRVAL_P(zparams
), name_str
, name_len
+ 1, (void *) &zparam
)) {
1099 RETVAL_ZVAL(*zparam
, 1, 0);
1102 zval_ptr_dtor(&zparams
);
1105 ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_offsetUnset
, 0, 0, 1)
1106 ZEND_ARG_INFO(0, name
)
1107 ZEND_END_ARG_INFO();
1108 PHP_METHOD(HttpParams
, offsetUnset
)
1114 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &name_str
, &name_len
)) {
1118 zparams
= php_http_zsep(1, IS_ARRAY
, zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), 0 TSRMLS_CC
));
1120 zend_symtable_del(Z_ARRVAL_P(zparams
), name_str
, name_len
+ 1);
1121 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), zparams TSRMLS_CC
);
1123 zval_ptr_dtor(&zparams
);
1126 ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_offsetSet
, 0, 0, 2)
1127 ZEND_ARG_INFO(0, name
)
1128 ZEND_ARG_INFO(0, value
)
1129 ZEND_END_ARG_INFO();
1130 PHP_METHOD(HttpParams
, offsetSet
)
1135 zval
**zparam
, *zparams
;
1137 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sz", &name_str
, &name_len
, &nvalue
)) {
1141 zparams
= php_http_zsep(1, IS_ARRAY
, zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), 0 TSRMLS_CC
));
1144 if (Z_TYPE_P(nvalue
) == IS_ARRAY
) {
1147 if (SUCCESS
== zend_symtable_find(Z_ARRVAL_P(zparams
), name_str
, name_len
+ 1, (void *) &zparam
)) {
1148 new_zparam
= php_http_zsep(1, IS_ARRAY
, *zparam
);
1149 array_join(Z_ARRVAL_P(nvalue
), Z_ARRVAL_P(new_zparam
), 0, 0);
1151 new_zparam
= nvalue
;
1152 Z_ADDREF_P(new_zparam
);
1154 add_assoc_zval_ex(zparams
, name_str
, name_len
+ 1, new_zparam
);
1158 if (SUCCESS
== zend_symtable_find(Z_ARRVAL_P(zparams
), name_str
, name_len
+ 1, (void *) &zparam
)) {
1159 tmp
= php_http_zsep(1, IS_ARRAY
, *zparam
);
1166 add_assoc_zval_ex(tmp
, ZEND_STRS("value"), nvalue
);
1167 add_assoc_zval_ex(zparams
, name_str
, name_len
+ 1, tmp
);
1170 zval
*tmp
= php_http_ztyp(IS_STRING
, nvalue
), *arr
;
1174 add_assoc_bool_ex(arr
, ZEND_STRS("value"), 1);
1175 add_assoc_zval_ex(zparams
, Z_STRVAL_P(tmp
), Z_STRLEN_P(tmp
) + 1, arr
);
1176 zval_ptr_dtor(&tmp
);
1179 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), zparams TSRMLS_CC
);
1180 zval_ptr_dtor(&zparams
);
1183 static zend_function_entry php_http_params_methods
[] = {
1184 PHP_ME(HttpParams
, __construct
, ai_HttpParams___construct
, ZEND_ACC_PUBLIC
|ZEND_ACC_CTOR
|ZEND_ACC_FINAL
)
1186 PHP_ME(HttpParams
, toArray
, ai_HttpParams_toArray
, ZEND_ACC_PUBLIC
)
1187 PHP_ME(HttpParams
, toString
, ai_HttpParams_toString
, ZEND_ACC_PUBLIC
)
1188 ZEND_MALIAS(HttpParams
, __toString
, toString
, ai_HttpParams_toString
, ZEND_ACC_PUBLIC
)
1190 PHP_ME(HttpParams
, offsetExists
, ai_HttpParams_offsetExists
, ZEND_ACC_PUBLIC
)
1191 PHP_ME(HttpParams
, offsetUnset
, ai_HttpParams_offsetUnset
, ZEND_ACC_PUBLIC
)
1192 PHP_ME(HttpParams
, offsetSet
, ai_HttpParams_offsetSet
, ZEND_ACC_PUBLIC
)
1193 PHP_ME(HttpParams
, offsetGet
, ai_HttpParams_offsetGet
, ZEND_ACC_PUBLIC
)
1195 EMPTY_FUNCTION_ENTRY
1198 zend_class_entry
*php_http_params_class_entry
;
1200 PHP_MINIT_FUNCTION(http_params
)
1202 zend_class_entry ce
= {0};
1204 INIT_NS_CLASS_ENTRY(ce
, "http", "Params", php_http_params_methods
);
1205 php_http_params_class_entry
= zend_register_internal_class(&ce TSRMLS_CC
);
1206 php_http_params_class_entry
->create_object
= php_http_params_object_new
;
1207 zend_class_implements(php_http_params_class_entry TSRMLS_CC
, 1, zend_ce_arrayaccess
);
1209 zend_declare_class_constant_stringl(php_http_params_class_entry
, ZEND_STRL("DEF_PARAM_SEP"), ZEND_STRL(",") TSRMLS_CC
);
1210 zend_declare_class_constant_stringl(php_http_params_class_entry
, ZEND_STRL("DEF_ARG_SEP"), ZEND_STRL(";") TSRMLS_CC
);
1211 zend_declare_class_constant_stringl(php_http_params_class_entry
, ZEND_STRL("DEF_VAL_SEP"), ZEND_STRL("=") TSRMLS_CC
);
1212 zend_declare_class_constant_stringl(php_http_params_class_entry
, ZEND_STRL("COOKIE_PARAM_SEP"), ZEND_STRL("") TSRMLS_CC
);
1214 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_RAW"), PHP_HTTP_PARAMS_RAW TSRMLS_CC
);
1215 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_ESCAPED"), PHP_HTTP_PARAMS_ESCAPED TSRMLS_CC
);
1216 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_URLENCODED"), PHP_HTTP_PARAMS_URLENCODED TSRMLS_CC
);
1217 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_DIMENSION"), PHP_HTTP_PARAMS_DIMENSION TSRMLS_CC
);
1218 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_RFC5987"), PHP_HTTP_PARAMS_RFC5987 TSRMLS_CC
);
1219 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_RFC5988"), PHP_HTTP_PARAMS_RFC5988 TSRMLS_CC
);
1220 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_DEFAULT"), PHP_HTTP_PARAMS_DEFAULT TSRMLS_CC
);
1221 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_QUERY"), PHP_HTTP_PARAMS_QUERY TSRMLS_CC
);
1223 zend_declare_property_null(php_http_params_class_entry
, ZEND_STRL("params"), ZEND_ACC_PUBLIC TSRMLS_CC
);
1224 zend_declare_property_stringl(php_http_params_class_entry
, ZEND_STRL("param_sep"), ZEND_STRL(","), ZEND_ACC_PUBLIC TSRMLS_CC
);
1225 zend_declare_property_stringl(php_http_params_class_entry
, ZEND_STRL("arg_sep"), ZEND_STRL(";"), ZEND_ACC_PUBLIC TSRMLS_CC
);
1226 zend_declare_property_stringl(php_http_params_class_entry
, ZEND_STRL("val_sep"), ZEND_STRL("="), ZEND_ACC_PUBLIC TSRMLS_CC
);
1227 zend_declare_property_long(php_http_params_class_entry
, ZEND_STRL("flags"), PHP_HTTP_PARAMS_DEFAULT
, ZEND_ACC_PUBLIC TSRMLS_CC
);
1237 * vim600: noet sw=4 ts=4 fdm=marker
1238 * vim<600: noet sw=4 ts=4