[GRASS-SVN] r66393 - grass/trunk/scripts/g.extension

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Oct 1 09:11:12 PDT 2015


Author: martinl
Date: 2015-10-01 09:11:12 -0700 (Thu, 01 Oct 2015)
New Revision: 66393

Modified:
   grass/trunk/scripts/g.extension/g.extension.py
Log:
g.extension: check content-type of downloaded addons file (must be a zip file)

Modified: grass/trunk/scripts/g.extension/g.extension.py
===================================================================
--- grass/trunk/scripts/g.extension/g.extension.py	2015-10-01 10:39:24 UTC (rev 66392)
+++ grass/trunk/scripts/g.extension/g.extension.py	2015-10-01 16:11:12 UTC (rev 66393)
@@ -1056,7 +1056,10 @@
     elif source in ['remote_zip', 'official']:
         # we expect that the module.zip file is not by chance in the archive
         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)
         fix_newlines(directory)
     elif source.startswith('remote_') and \



More information about the grass-commit mailing list