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

Handle AssetIds with invalid URI characters #1140

Merged
merged 4 commits into from
Mar 9, 2018
Merged

Conversation

natebosch
Copy link
Member

Fixes #1134

Rewrite the URI encoding for AssetId to be more robust by using the
built in URI escaping when using pathSegments instead of path.

Delete a duplicate of the AssetId test file.

Fixes #1134

Rewrite the URI encoding for AssetId to be more robust by using the
built in URI escaping when using `pathSegments` instead of `path`.

Delete a duplicate of the AssetId test file.
@googlebot googlebot added the cla: yes Google is happy with the PR contributors label Mar 9, 2018
@natebosch
Copy link
Member Author

We had talked about just throwing away any file path that had an invalid character, but I think this is probably the better fix.

@@ -1,71 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

were the rest of these all dupes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, the other ones in this directory are testing build_runner stuff.

final scheme = isLib ? 'package' : 'asset';
final pathSegments = isLib ? originalSegments.skip(1) : originalSegments;
return new Uri(
scheme: scheme, pathSegments: [id.package]..addAll(pathSegments));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so pathSegments escapes and path doesn't?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path escapes some stuff, but not everything. It leaves delimiters, even when they are invalid.
https://github.com/dart-lang/sdk/blob/80a571d5460bbc734e709d7437af2c7df11e582a/sdk/lib/core/uri.dart#L85

pathSegments escapes everything which is, I think, what we want.

@natebosch natebosch merged commit 2a60e79 into master Mar 9, 2018
@natebosch natebosch deleted the asset-id-valid-uri branch March 9, 2018 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google is happy with the PR contributors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants