Disallow empty platforms and specific platforms when parsing manifest for plugins (#49262)

This commit is contained in:
Jenn Magder
2020-01-22 10:52:23 -08:00
committed by GitHub
parent 320c19e4b9
commit 8a3c98633a
2 changed files with 30 additions and 1 deletions

View File

@@ -202,9 +202,12 @@ class Plugin {
static List<String> _validateMultiPlatformYaml(YamlMap yaml) {
bool isInvalid(String key, bool Function(YamlMap) validate) {
if (!yaml.containsKey(key)) {
return false;
}
final dynamic value = yaml[key];
if (value is! YamlMap) {
return false;
return true;
}
final YamlMap yamlValue = value as YamlMap;
if (yamlValue.containsKey('default_package')) {
@@ -212,6 +215,10 @@ class Plugin {
}
return !validate(yamlValue);
}
if (yaml == null) {
return <String>['Invalid "platforms" specification.'];
}
final List<String> errors = <String>[];
if (isInvalid(AndroidPlugin.kConfigKey, AndroidPlugin.validate)) {
errors.add('Invalid "android" plugin specification.');