[flutter_tools] Handle special characters during conversion of asset manifest paths into URIs (#48829)

This commit is contained in:
Jason Simmons
2020-01-15 16:43:02 -08:00
committed by Flutter GitHub Bot
parent aeb12144e6
commit 63016c8900
2 changed files with 23 additions and 1 deletions

View File

@@ -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.');
}

View File

@@ -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<Uri> 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', () {