You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
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 offile
and a fragment of "2.dart
. When the front-end later callsUri.toFilePath
, that throws because it cannot be used on URIs with queries or fragments.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) orUri.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, butc:
is not necessarily a scheme on Windows (and we might want to support both/
and\
as path separator on Windows).(See: flutter/flutter#15332)
The text was updated successfully, but these errors were encountered: