Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid URI, if array in query params #3

Open
tbaddade opened this issue Jun 16, 2020 · 1 comment
Open

Invalid URI, if array in query params #3

tbaddade opened this issue Jun 16, 2020 · 1 comment

Comments

@tbaddade
Copy link

I have a problem with an array in query params.

Example:

$url = 'https://example.localhost/?fields[articles]=title';
$uri = new Uri($url, UriParser::MODE_UTF8);

Error:

InvalidArgumentException 
/Kit-UrlParser/src/Uri.php:54

I have no influence on the generation of the Urls, because they come from another extension.
Have you got a solution for this problem?

@Riimu
Copy link
Owner

Riimu commented Jun 17, 2020

Strictly speaking, the problem is that [ and ] are not valid characters in the query part of the URI according to rfc3986 and this library was originally created with the intention of validating URLs strictly according to that RFC.

The extension you are using really ought to build URLs using logic similar to http_build_query(), so that the [] characters would get encoded properly like fields%5Barticles%5D=title.

But, I do realize that unfortunately a lot of places do not really conform to the spec very strictly so I might have to think about adding some kind of lenient parsing mode that would allow more characters than what the spec defines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants