zval **args;
zval **val;
} current;
+ unsigned quotes:1;
+ unsigned escape:1;
} php_http_params_state_t;
static inline void sanitize_default(zval *zv TSRMLS_DC)
MAKE_STD_ZVAL(val);
if (opts->defval) {
-#if PHP_VERSION_ID >= 50400
ZVAL_COPY_VALUE(val, opts->defval);
-#else
- val->value = opts->defval->value;
- Z_TYPE_P(val) = Z_TYPE_P(opts->defval);
-#endif
zval_copy_ctor(val);
} else {
ZVAL_TRUE(val);
{
php_http_params_token_t **sep = separators;
+ 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;
PHP_HTTP_API HashTable *php_http_params_parse(HashTable *params, const php_http_params_opts_t *opts TSRMLS_DC)
{
- php_http_params_state_t state = {{NULL,0}, {NULL,0}, {NULL,0}, {NULL,0}, {NULL,NULL,NULL}};
+ php_http_params_state_t state = {{NULL,0}, {NULL,0}, {NULL,0}, {NULL,0}, {NULL,NULL,NULL}, 0, 0};
state.input.str = opts->input.str;
state.input.len = opts->input.len;
}
while (state.input.len) {
- if (*state.input.str == '\\') {
- ++state.input.str;
- --state.input.len;
- } else if (!state.param.str) {
+ if (*state.input.str == '"' && !state.escape) {
+ state.quotes = !state.quotes;
+ } else {
+ state.escape = (*state.input.str == '\\');
+ }
+
+ if (!state.param.str) {
/* initialize */
skip_sep(0, &state, opts->param, opts->arg, opts->val TSRMLS_CC);
state.param.str = state.input.str;
}
}
}
-
+
if (state.input.len) {
++state.input.str;
--state.input.len;
function testParse() {
$header = "Foo: bar\nBar: foo\n";
$this->assertEquals(array("Foo"=>"bar","Bar"=>"foo"), http\Header::parse($header));
- $header = http\Header::parse($header, "http\\Header");
- $this->assertCount(2, $header);
- $this->assertContainsOnlyInstancesOf("http\\Header", $header);
+ $headers = http\Header::parse($header, "http\\Header");
+ $this->assertCount(2, $headers);
+ $this->assertContainsOnlyInstancesOf("http\\Header", $headers);
}
function testParseError() {
}
function testParamsWithArgs() {
- $header = new http\Header("Custom", '"foo" is "bar". "bar" is "bis" where "bis" is 3.');
+ $header = new http\Header("Custom", '"foo" is "bar". "bar" is "bis" where "bis" is "where".');
$this->assertEquals(
array(
"foo" => array("value" => "bar", "arguments" => array()),
- "bar" => array("value" => "baz", "arguments" => array("baz" => "3"))
+ "bar" => array("value" => "bis", "arguments" => array("bis" => "where"))
),
$header->getParams(".", "where", "is")->params
);