-
Notifications
You must be signed in to change notification settings - Fork 1.7k
uri.parse doesn't seem to follow url.spec.whatwg.org #29420
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
Comments
We are trying to follow RFC 3986, while being more lenient than required (escaping some invalid characters, but not all) and performing some of the possible normalizations. We are currently not trying to match the whatwg version. We should consider whether the whatwg parsing algorithm is worth adapting to. It's likely to be what some users will expect (as this bug testifies to), but we won't match all parts of it (for example, we don't have blobs). |
I would expect user expectations have changed a bit in the 12 years since RFC 3986. :) That said, this isn't a particularly high priority bug. But next time we do go looking at the url library the whatwg had a ton of tests for making it easy to conform to its url spec. |
It could be fixed ? |
For no good reason (other than that I used to do this kind of thing as my day job) I wrote a test harness to see how well Dart's Uri.parse passes WHATWG's suite: The major difference is that Uri.parse is way more strict (throws exceptions) where WHATWG's seems to try real hard to always give you an answer even for "invalid" urls. WHATWG also expects something like the Uri class to expose more of the component details, which as far as I can tell Dart's Uri class doesn't currently. Regardless, this remains a low priority bug IMO, I just did this for fun tonight. :) |
Here are the results for the curious: https://gist.github.com/eseidelGoogle/99681c9b362596f2b45427d16896864e Caveats: There are also likely bugs in my harness. Certainly I'm not checking everything the tests expect me to due to limited component accessors on Uri. Also, I've not compared Chrome or Firefox or other Url implementations to know if anyone actually conforms to that suite. |
Our current plan for Dart 2 is to change the We do expose one property less than the WhatWG URL (we don't separate |
Is this still planned? Will it need to wait for Dart 3? |
Apparently due to that issue it's hard to implement Google's encoded polyline https://developers.google.com/maps/documentation/utilities/polylinealgorithm |
You'll probably have to wait for Dart 3, or us adding an alternative to As for main() {
var uri = Uri.parse("http://example.org/whatnot");
var v = uri.resolveUri(new Uri(query: "\x00\xff[]=&#/\\:?"));
print(v);
print(Uri.decodeQueryComponent(v.query));
} |
More interest has been shown on making the Dart We should consider whether it's viable to change the If we want to change the Dart Getting the functionality from Cronet would be optimal where it's available. |
This was brought to my attention due to:
flutter/flutter#9529
For example:
Uri.parse('https://www.google.com/#q=[') throws.
https://url.spec.whatwg.org/#path-state
Otherwise, run these steps:
If c is not a URL code point and not U+0025 (%), validation error.
If c is U+0025 (%) and remaining does not start with two ASCII hex digits, validation error.
UTF-8 percent encode c using the path percent-encode set, and append the result to buffer.
which my understanding is validation error doesn't actually cause the parse to fail:
"A validation error does not mean that the parser terminates. Termination of a parser is always stated explicitly, e.g., through a return statement."
It looks like if we wanted to conform, there are tests:
https://github.com/w3c/web-platform-tests/tree/master/url
We would just need to write a dart-based harness for running them.
The text was updated successfully, but these errors were encountered: