Skip to content

Commit 2fe364f

Browse files
authored
flutter_tools: URI-decode data: URI content (flutter#14627)
In getFlutterRoot(), scripts loaded via data: URIs are URI encoded. getFlutterRoot() scans the contents of the data for the file:// URI path of the Flutter SDK, which itself is URI-encoded. The end result is that if the SDK path contains a space, the embedded file:// URI will contain a %20. When this is encoded in a data: URI, the contents are URI-encoded, resulting in %2520, since the % is encoded to %25. This patch decodes the data: URI before extracting the SDK file:// URI.
1 parent fd6baba commit 2fe364f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/flutter_tools/test/src/common.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ String getFlutterRoot() {
3232
scriptUri = platform.script;
3333
break;
3434
case 'data':
35-
final RegExp flutterTools = new RegExp(r'(file://[^ ;]*[/\\]flutter_tools[^%]+\.dart)%');
36-
final Match match = flutterTools.firstMatch(platform.script.path);
35+
final RegExp flutterTools = new RegExp(r'(file://[^"]*[/\\]flutter_tools[/\\][^"]+\.dart)', multiLine: true);
36+
final Match match = flutterTools.firstMatch(Uri.decodeFull(platform.script.path));
3737
if (match == null)
3838
throw invalidScript();
3939
scriptUri = Uri.parse(match.group(1));

0 commit comments

Comments
 (0)