Browse Source

g.extension: check content-type of downloaded addons file (must be a zip file)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@66393 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 9 years ago
parent
commit
d8dbd2d25e
1 changed files with 4 additions and 1 deletions
  1. 4 1
      scripts/g.extension/g.extension.py

+ 4 - 1
scripts/g.extension/g.extension.py

@@ -1056,7 +1056,10 @@ def download_source_code(source, url, name, outdev,
     elif source in ['remote_zip', 'official']:
     elif source in ['remote_zip', 'official']:
         # we expect that the module.zip file is not by chance in the archive
         # we expect that the module.zip file is not by chance in the archive
         zip_name = os.path.join(tmpdir, 'extension.zip')
         zip_name = os.path.join(tmpdir, 'extension.zip')
-        urlretrieve(url, zip_name)
+        f, h = urlretrieve(url, zip_name)
+        if h.get('content-type', '') != 'application/zip':
+            grass.fatal(_("Extension <%s> not found") % name)
+            
         extract_zip(name=zip_name, directory=directory, tmpdir=tmpdir)
         extract_zip(name=zip_name, directory=directory, tmpdir=tmpdir)
         fix_newlines(directory)
         fix_newlines(directory)
     elif source.startswith('remote_') and \
     elif source.startswith('remote_') and \