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

Front-end does not accept file-names containing # or ?. #34222

Open
lrhn opened this issue Aug 22, 2018 · 0 comments
Open

Front-end does not accept file-names containing # or ?. #34222

lrhn opened this issue Aug 22, 2018 · 0 comments
Labels
area-front-end type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@lrhn
Copy link
Member

lrhn commented Aug 22, 2018

The front-end uses Uri.parse to handle incoming file names. That's unsafe since file names may contain characters that are meaningful in URI parsing, in particular # and ?.

When that happens, like dart file#2.dart, the input file name is parsed into a path of file and a fragment of "2.dart. When the front-end later calls Uri.toFilePath, that throws because it cannot be used on URIs with queries or fragments.

Unsupported operation: Cannot extract a file path from a URI with a query component 
#0      _Uri.toFilePath (dart:core/uri.dart:2610)
#1      _IoFileSystemEntity.exists (package:front_end/src/api_prototype/standard_file_system.dart:55)<asynchronous suspension>
#2      HybridFileSystemEntity.exists (package:front_end/src/fasta/hybrid_file_system.dart:51)<asynchronous suspension>
#3      ProcessedOptions.validateOptions (package:front_end/src/base/processed_options.dart:268)<asynchronous suspension>
#4      CompilerContext.runWithOptions.<anonymous closure>(package:front_end/src/fasta/compiler_context.dart:130)
<asynchronous suspension>
...

If the front-end accepts user command-line inputs which are allowed to be either URIs or file paths, then the front-end needs to distinguish those cases before calling either Uri.parse (for URI inputs) or Uri.file (for non-URI file paths).

The logic must probably be heuristic. Relative paths that do not contain ? or # can be either. Anything with a scheme must be a URI, but c: is not necessarily a scheme on Windows (and we might want to support both / and \ as path separator on Windows).

(See: flutter/flutter#15332)

@lrhn lrhn added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) area-front-end labels Aug 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

1 participant