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

Uri.parse fails to parse a valid Url #34451

Open
drbcode opened this Issue Sep 12, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@drbcode

drbcode commented Sep 12, 2018

This code throws an exception:

main(List<String> arguments) {
  Uri.parse('http://www.example.com/?xts[0]=hello');
}

Error message

Unhandled exception:
FormatException: Invalid character (at character 28)
http://www.example.com/?xts[0]=hello
                           ^

Maybe it is not a valid URL but, Facebook is using these kind of URLs all over the place so parsing them with dart throws exceptions, for example this URL can't be parsed using dart
https://www.facebook.com/me/posts/1234?__xts__[0]=XQg6uCX3vuYDQ

In my use case, I'm running Uri.parse in a background page where I don't have access to window object of original tab. Manually splitting host , pathname and valid parameters might lead to more errors.

Dart sdk version: 2.0.0

I have chrome extensions that are deployed in production that parse facebook URLs of these kind..

Dart pad example:
https://dartpad.dartlang.org/991e12994caea2c178e437d42234a893

@lrhn

This comment has been minimized.

Show comment
Hide comment
@lrhn

lrhn Sep 12, 2018

Member

It is indeed not a valid URL as defined by RFC 3986. The [ and ] characters are general delimiters, and are not included in pchar.

It's still annoying that it isn't allowed.
I believe I have allowed other invalid characters, so let's see if we can allow this one too in the path/query/fragment parts (not in the host part, where it actually means something).

Member

lrhn commented Sep 12, 2018

It is indeed not a valid URL as defined by RFC 3986. The [ and ] characters are general delimiters, and are not included in pchar.

It's still annoying that it isn't allowed.
I believe I have allowed other invalid characters, so let's see if we can allow this one too in the path/query/fragment parts (not in the host part, where it actually means something).

@drbcode

This comment has been minimized.

Show comment
Hide comment
@drbcode

drbcode Sep 12, 2018

I came across this answer on stackoverflow where PHP programmers are using parameters like
?cars[]=Saab
to pass an array within a query string for multi-value form fields.

It's not standardised but still big sites like facebook are using it.
https://stackoverflow.com/questions/6243051/how-to-pass-an-array-within-a-query-string

drbcode commented Sep 12, 2018

I came across this answer on stackoverflow where PHP programmers are using parameters like
?cars[]=Saab
to pass an array within a query string for multi-value form fields.

It's not standardised but still big sites like facebook are using it.
https://stackoverflow.com/questions/6243051/how-to-pass-an-array-within-a-query-string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment