Unverified Commit 846418b6 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] fix crash if the platform section was a list (#60927)

Missed validation to go with cast. Added test case to reproduce.
parent db5a62b0
...@@ -214,6 +214,10 @@ class Plugin { ...@@ -214,6 +214,10 @@ class Plugin {
} }
if (usesNewPluginFormat) { if (usesNewPluginFormat) {
if (yaml['platforms'] != null && yaml['platforms'] is! YamlMap) {
const String errorMessage = 'flutter.plugin.platforms should be a map with the platform name as the key';
return <String>[errorMessage];
}
return _validateMultiPlatformYaml(yaml['platforms'] as YamlMap); return _validateMultiPlatformYaml(yaml['platforms'] as YamlMap);
} else { } else {
return _validateLegacyYaml(yaml); return _validateLegacyYaml(yaml);
......
...@@ -943,6 +943,26 @@ flutter: ...@@ -943,6 +943,26 @@ flutter:
<String, dynamic>{'pluginClass': 'SomeClass', <String, dynamic>{'pluginClass': 'SomeClass',
'package': 'com.example'}); 'package': 'com.example'});
}); });
testWithoutContext('FlutterManifest validates a platform section that is a list '
'instead of a map', () {
const String manifest = '''
name: test
flutter:
plugin:
platforms:
- android
''';
final BufferLogger logger = BufferLogger.test();
final FlutterManifest flutterManifest = FlutterManifest.createFromString(
manifest,
logger: logger,
);
expect(flutterManifest, null);
expect(logger.errorText,
contains('flutter.plugin.platforms should be a map with the platform name as the key'));
});
} }
Matcher matchesManifest({ Matcher matchesManifest({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment