parseQuery example


        if ('' == $route) {
            throw new HttpException($permanent ? 410 : 404);
        }

        $attributes = [];
        if (false === $ignoreAttributes || \is_array($ignoreAttributes)) {
            $attributes = $request->attributes->get('_route_params');

            if ($keepQueryParams) {
                if ($query = $request->server->get('QUERY_STRING')) {
                    $query = HeaderUtils::parseQuery($query);
                } else {
                    $query = $request->query->all();
                }

                $attributes = array_merge($query$attributes);
            }

            unset($attributes['route']$attributes['permanent']$attributes['ignoreAttributes']$attributes['keepRequestMethod']$attributes['keepQueryParams']);
            if ($ignoreAttributes) {
                $attributes = array_diff_key($attributesarray_flip($ignoreAttributes));
            }
        }

    public static function normalizeQueryString(?string $qs): string
    {
        if ('' === ($qs ?? '')) {
            return '';
        }

        $qs = HeaderUtils::parseQuery($qs);
        ksort($qs);

        return http_build_query($qs, '', '&', \PHP_QUERY_RFC3986);
    }

    /** * Enables support for the _method request parameter to determine the intended HTTP method. * * Be warned that enabling this feature might lead to CSRF issues in your code. * Check that you are using CSRF tokens when required. * If the HTTP method parameter override is enabled, an html-form with method "POST" can be altered * and used to send a "PUT" or "DELETE" request via the _method request parameter. * If these methods are not protected against CSRF, this presents a possible vulnerability. * * The HTTP method can only be overridden when the real HTTP method is POST. * * @return void */
'attachment', 'foo\bar.html'],
            ['attachment', '\foo.html'],
            ['attachment', 'föö.html'],
        ];
    }

    /** * @dataProvider provideParseQuery */
    public function testParseQuery(string $query, string $expected = null)
    {
        $this->assertSame($expected ?? $queryhttp_build_query(HeaderUtils::parseQuery($query), '', '&'));
    }

    public static function provideParseQuery()
    {
        return [
            ['a=b&c=d'],
            ['a.b=c'],
            ['a+b=c'],
            ["a\0b=c", 'a='],
            ['a%00b=c', 'a=c'],
            ['a[b=c', 'a%5Bb=c'],
            [

    public static function normalizeQueryString(?string $qs): string
    {
        if ('' === ($qs ?? '')) {
            return '';
        }

        $qs = HeaderUtils::parseQuery($qs);
        ksort($qs);

        return http_build_query($qs, '', '&', \PHP_QUERY_RFC3986);
    }

    /** * Enables support for the _method request parameter to determine the intended HTTP method. * * Be warned that enabling this feature might lead to CSRF issues in your code. * Check that you are using CSRF tokens when required. * If the HTTP method parameter override is enabled, an html-form with method "POST" can be altered * and used to send a "PUT" or "DELETE" request via the _method request parameter. * If these methods are not protected against CSRF, this presents a possible vulnerability. * * The HTTP method can only be overridden when the real HTTP method is POST. * * @return void */
Home | Imprint | This part of the site doesn't use cookies.