MAKE_STD_ZVAL(key);
ZVAL_NULL(key);
+ if (opts->flags & PHP_HTTP_PARAMS_RFC5988) {
+ state->param.str += 1; /* < */
+ state->param.len -= 2; /* > */
+ }
sanitize_key(opts->flags, state->param.str, state->param.len, key, &rfc5987 TSRMLS_CC);
state->rfc5987 = rfc5987;
if (Z_TYPE_P(key) != IS_STRING) {
}
while (state.input.len) {
- if (*state.input.str == '"' && !state.escape) {
+ if ((opts->flags & PHP_HTTP_PARAMS_RFC5988) && !state.arg.str) {
+ if (!state.param.str && *state.input.str == '<') {
+ state.quotes = 1;
+ } else if (*state.input.str == '>') {
+ state.quotes = 0;
+ }
+ } else if (*state.input.str == '"' && !state.escape) {
state.quotes = !state.quotes;
} else {
state.escape = (*state.input.str == '\\');
}
}
+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)
+{
+ char *str;
+ size_t len;
+
+ if (buf->used) {
+ php_http_buffer_append(buf, ass, asl);
+ }
+
+ prepare_key(flags, key_str, key_len, &str, &len TSRMLS_CC);
+ php_http_buffer_appends(buf, "<");
+ php_http_buffer_append(buf, str, len);
+ php_http_buffer_appends(buf, ">");
+ efree(str);
+}
+
static inline void shift_val(php_http_buffer_t *buf, zval *zvalue, const char *vss, size_t vsl, unsigned flags TSRMLS_DC)
{
if (Z_TYPE_P(zvalue) != IS_BOOL) {
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);
+ if (flags & PHP_HTTP_PARAMS_RFC5988) {
+ shift_rfc5988(buf, key_str, key_len, pss, psl, flags TSRMLS_CC);
+ } else {
+ shift_key(buf, key_str, key_len, pss, psl, flags TSRMLS_CC);
+ }
shift_val(buf, zvalue, vss, vsl, flags TSRMLS_CC);
}
}
zend_declare_class_constant_long(php_http_params_class_entry, ZEND_STRL("PARSE_URLENCODED"), PHP_HTTP_PARAMS_URLENCODED TSRMLS_CC);
zend_declare_class_constant_long(php_http_params_class_entry, ZEND_STRL("PARSE_DIMENSION"), PHP_HTTP_PARAMS_DIMENSION TSRMLS_CC);
zend_declare_class_constant_long(php_http_params_class_entry, ZEND_STRL("PARSE_RFC5987"), PHP_HTTP_PARAMS_RFC5987 TSRMLS_CC);
+ zend_declare_class_constant_long(php_http_params_class_entry, ZEND_STRL("PARSE_RFC5988"), PHP_HTTP_PARAMS_RFC5988 TSRMLS_CC);
zend_declare_class_constant_long(php_http_params_class_entry, ZEND_STRL("PARSE_DEFAULT"), PHP_HTTP_PARAMS_DEFAULT TSRMLS_CC);
zend_declare_class_constant_long(php_http_params_class_entry, ZEND_STRL("PARSE_QUERY"), PHP_HTTP_PARAMS_QUERY TSRMLS_CC);