From 63016c890000da771efd52a57489cac5c8c46209 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Wed, 15 Jan 2020 16:43:02 -0800 Subject: [PATCH] [flutter_tools] Handle special characters during conversion of asset manifest paths into URIs (#48829) --- .../lib/src/flutter_manifest.dart | 2 +- .../general.shard/flutter_manifest_test.dart | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/flutter_tools/lib/src/flutter_manifest.dart b/packages/flutter_tools/lib/src/flutter_manifest.dart index 36c25efece..4f5bc47367 100644 --- a/packages/flutter_tools/lib/src/flutter_manifest.dart +++ b/packages/flutter_tools/lib/src/flutter_manifest.dart @@ -204,7 +204,7 @@ class FlutterManifest { } final String stringAsset = asset as String; try { - results.add(Uri.parse(Uri.encodeFull(stringAsset))); + results.add(Uri(pathSegments: stringAsset.split('/'))); } on FormatException { globals.printError('Asset manifest contains invalid uri: $asset.'); } diff --git a/packages/flutter_tools/test/general.shard/flutter_manifest_test.dart b/packages/flutter_tools/test/general.shard/flutter_manifest_test.dart index 093e9cd1e5..6105e75b4b 100644 --- a/packages/flutter_tools/test/general.shard/flutter_manifest_test.dart +++ b/packages/flutter_tools/test/general.shard/flutter_manifest_test.dart @@ -619,6 +619,28 @@ flutter: expect(testLogger.errorText, contains('Asset manifest contains a null or empty uri.')); expect(assets.length, 1); }); + + testUsingContext('Special characters in asset URIs', () async { + const String manifest = ''' +name: test +dependencies: + flutter: + sdk: flutter +flutter: + uses-material-design: true + assets: + - lib/gallery/abc#xyz + - lib/gallery/abc?xyz + - lib/gallery/aaa bbb +'''; + final FlutterManifest flutterManifest = FlutterManifest.createFromString(manifest); + final List assets = flutterManifest.assets; + + expect(assets.length, 3); + expect(assets[0].path, 'lib/gallery/abc%23xyz'); + expect(assets[1].path, 'lib/gallery/abc%3Fxyz'); + expect(assets[2].path, 'lib/gallery/aaa%20bbb'); + }); }); group('FlutterManifest with MemoryFileSystem', () {