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

Incorrect resolution of package-URLs in Dartium #17662

Closed
peter-ahe-google opened this issue Mar 20, 2014 · 15 comments
Closed

Incorrect resolution of package-URLs in Dartium #17662

peter-ahe-google opened this issue Mar 20, 2014 · 15 comments
Labels
P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@peter-ahe-google
Copy link
Contributor

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)

@peter-ahe-google
Copy link
Contributor Author

FWIW, this prevents me from developing Try Dart! on Dartium.

@peter-ahe-google
Copy link
Contributor Author

These tests are now failing due to this problem:

utils/dummy_compiler_test
utils/recursive_import_test
utils/source_mirrors_test

@vsmenon
Copy link
Member

vsmenon commented Jun 20, 2014

Set owner to @vsmenon.
Added this to the 1.6 milestone.
Removed Priority-Unassigned label.
Added Priority-High label.

@vsmenon
Copy link
Member

vsmenon commented Jun 20, 2014

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?

@peter-ahe-google
Copy link
Contributor Author

Package imports are independent of pub. It is a simple mechanism about resolving one URI against another. Pub builds on that.

@vsmenon
Copy link
Member

vsmenon commented Jun 24, 2014

Fixed in our Blink branch (r176820). Merged into Dart DEPS as of r37641 on bleeding edge.


Added Fixed label.

@whesse
Copy link
Member

whesse commented Jul 2, 2014

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.

@vsmenon
Copy link
Member

vsmenon commented Aug 6, 2014

Removed this from the 1.6 milestone.
Added this to the 1.7 milestone.

@vsmenon
Copy link
Member

vsmenon commented Sep 16, 2014

Removed this from the 1.7 milestone.
Added this to the 1.8 milestone.

@lrhn
Copy link
Member

lrhn commented Nov 3, 2014

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.
It would be more correct if package URIs were written as "package://foo/foo.dart", but that's probably a little late to change that now.

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".

@peter-ahe-google
Copy link
Contributor Author

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.

@vsmenon
Copy link
Member

vsmenon commented Nov 11, 2014

Removed this from the 1.8 milestone.
Added this to the 1.9 milestone.

@vsmenon
Copy link
Member

vsmenon commented Feb 17, 2015

Removed this from the 1.9 milestone.
Added this to the 1.10 milestone.

@vsmenon
Copy link
Member

vsmenon commented Apr 9, 2015

Removed the owner.
Added Triaged label.

@dgrove
Copy link
Contributor

dgrove commented Apr 17, 2015

Removed this from the 1.10 milestone.
Removed Priority-High label.
Added Priority-Medium label.

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed triaged labels Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

7 participants