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
Incorrect resolution of package-URLs in Dartium #17662
Comments
FWIW, this prevents me from developing Try Dart! on Dartium. |
These tests are now failing due to this problem: utils/dummy_compiler_test |
Set owner to @vsmenon. |
I need to look at the spec more closely, but practically speaking, do we really want to support this? It's a different package. Why is your code not importing package:bar.dart in the first place? E.g., should the user really assume that all packages are in the same place? |
Package imports are independent of pub. It is a simple mechanism about resolving one URI against another. Pub builds on that. |
Fixed in our Blink branch (r176820). Merged into Dart DEPS as of r37641 on bleeding edge. Added Fixed label. |
These tests are still failing on content_shell on Android. It is built from dartium.deps, so it should have the new fix, but they still fail. Added Accepted label. |
Package URIs are are badly specified. The first part of the "path" is really the package name, and it is not hierarchial. Using "../bar" should not allow you to go from package foo to package bar. Using "../bar.dart" relative to "package:foo/foo.dart" should either fail, because "package:bar.dart" is not a valid package URI, or it should act as if "foo" was the authority and give "package:foo/bar.dart". |
No, Lasse. That's not how it works. The first part of a package URI's path isn't special, and resolution is following RFC 3986, section 5 (Reference Resolution). When resolving a relative path in an import or a part in a library, simply follow https://tools.ietf.org/html/rfc3986#section-5, using the library URI (the absolute package URI) as base URI. This is precisely the mechanism implemented in dart2js, and the Dart VM, and this wasn't an accident. |
Removed the owner. |
Removed this from the 1.10 milestone. |
Serve the attached file from a web server, for example, as http://127.0.0.1/index.html.
Connect to the server using Dartium. Observe the following error in the console:
GET http://127.0.0.1/packages/foo/bar.dart 404 (Not Found)
Now connect the standalone Dart VM to the same server, for example:
dart http://127.0.0.1/main.dart
Observe that the standalone VM correctly prints:
Called bar
The problem is the ../ import in bug/packages/foo/foo.dart. Dartium doesn't resolve it correctly.
See RFC-3986 section 5 (Reference Resolution) http://tools.ietf.org/html/rfc3986#section-5
The base URI of the import is "package:foo/foo.dart".
The URI reference is "../bar.dart".
Resolving the latter against the former should yield:
"package:bar.dart", not "package:foo/bar.dart".
This is exactly what happens when using the Uri class from dart:core, for example:
main() {
Uri base = Uri.parse('package:foo/foo.dart');
Uri relative = '../bar.dart';
print('base = $base');
print('relative = $relative');
print('resolved = ${base.resolve(relative)}');
}
Attachment:
bug.zip (1.91 KB)
The text was updated successfully, but these errors were encountered: