Extra validation of the uploaded ZIP #73
BIN
extensions/tests/files/invalid-manifest-toml.zip
Normal file
BIN
extensions/tests/files/invalid-manifest-toml.zip
Normal file
Binary file not shown.
@ -78,6 +78,7 @@ EXPECTED_VALIDATION_ERRORS = {
|
||||
'invalid-no-manifest.zip': {
|
||||
'source': ['The manifest file is missing.'],
|
||||
},
|
||||
'invalid-manifest-toml.zip': {'source': ['Could not parse the manifest file.']},
|
||||
}
|
||||
|
||||
|
||||
|
@ -143,18 +143,16 @@ class FileForm(forms.ModelForm):
|
||||
errors.append(ValidationError(self.error_messages['invalid_zip_archive']))
|
||||
|
||||
manifest, error_codes = utils.read_manifest_from_zip(file_path)
|
||||
for code in error_codes:
|
||||
errors.append(ValidationError(self.error_messages[code]))
|
||||
|
||||
if manifest is None:
|
||||
errors.append(ValidationError(self.error_messages['missing_manifest_toml']))
|
||||
else:
|
||||
if manifest:
|
||||
ManifestValidator(manifest)
|
||||
ExtensionIDManifestValidator(manifest, self.extension)
|
||||
|
||||
self.cleaned_data['metadata'] = manifest
|
||||
self.cleaned_data['type'] = EXTENSION_SLUG_TYPES[manifest['type']]
|
||||
|
||||
for code in error_codes:
|
||||
errors.append(ValidationError(self.error_messages[code]))
|
||||
if errors:
|
||||
self.add_error('source', errors)
|
||||
|
||||
|
@ -110,6 +110,7 @@ def read_manifest_from_zip(archive_path):
|
||||
|
||||
if manifest_filepath is None:
|
||||
logger.info(f"File '{manifest_name}' not found in the archive.")
|
||||
error_codes.append('missing_manifest_toml')
|
||||
return None, error_codes
|
||||
|
||||
# Manifest file is expected to be no deeper than one directory down
|
||||
|
Loading…
Reference in New Issue
Block a user