Permalink
Browse files

Added fix and test for author field containing slashes (not allowed)

  • Loading branch information...
1 parent 47cda3e commit 7b252e5af9469ec2e70d98f88491d51db2e7f864 @elpaso elpaso committed Feb 6, 2013
@@ -22,6 +22,13 @@ class Meta:
model = Plugin
fields = ('description', 'author', 'email', 'icon', 'deprecated', 'homepage', 'tracker', 'repository', 'owners', 'tags')
+ def clean(self):
+ """
+ Check author
+ """
+ if self.cleaned_data.get('author') and not re.match(r'^[^/]+$', self.cleaned_data.get('author')):
+ raise ValidationError(_("Author name cannot contain slashes."))
+ return super(PluginForm, self).clean()
class PluginVersionForm(ModelForm):
"""
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+# Import the PyQt and QGIS libraries
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+from qgis.core import *
+
+
+class HelloWorld:
+
+ def __init__(self, iface):
+ # Save reference to the QGIS interface
+ self.iface = iface
+ self.canvas = iface.mapCanvas()
+
+ def initGui(self):
+ # Create action that will start plugin
+ self.action = QAction(QIcon(":/plugins/"), "&HelloWorld", self.iface.mainWindow())
+ # connect the action to the run method
+ QObject.connect(self.action, SIGNAL("activated()"), self.hello_world)
+
+ # Add toolbar button and menu item
+ self.iface.addPluginToMenu("HelloWorld", self.action)
+
+
+ def unload(self):
+ # Remove the plugin menu item and icon
+ self.iface.removePluginMenu("HelloWorld",self.action)
+
+
+
+ # run
+ def hello_world(self):
+ QMessageBox.information(self.iface.mainWindow(), QCoreApplication.translate('HelloWorld', "HelloWorld"), QCoreApplication.translate('HelloWorld', "HelloWorld"))
+ return
+
+
+
+
+if __name__ == "__main__":
+ pass
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+"""
+ This script initializes the plugin, making it known to QGIS.
+"""
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,31 @@
+[general]
+name=HelloWorld
+qgisMinimumVersion=1.8
+description=This is a test plugin for greeting the
+ (going multiline) world, version is 1.7
+version=version 1.8
+author=Alessandro/Pasotti èàò
+email=apasotti@gmail.com
+
+
+changelog=this is a very
+ very<br/>
+ very
+ very
+ very
+ very long multiline changelog
+
+
+tags= wkt, raster,hello world, spaced tag , tag
+
+tracker=http://bugs.itopen.it
+homepage=http://www.itopen.it
+repository=http://www.itopen.it/repo
+
+
+
+experimental=True
+
+
+; change icon...
+icon=icons/icon.png
@@ -4,4 +4,5 @@ Some can contain errors:
1.0_spaced (space in folder name)
1.2_md_txt_incomplete (metadata.txt with missin fields)
+1.8_author_slashes_error (slashes in author name: invalid)
@@ -74,6 +74,7 @@ def validator(package):
* zip contains __init__.py in first level dir
* mandatory metadata: ('name', 'description', 'version', 'qgisMinimumVersion', 'author', 'email')
* package_name regexp: [A-Za-z][A-Za-z0-9-_]+
+ * author regexp: [^/]+
"""
try:
@@ -178,6 +179,12 @@ def validator(package):
zip.close()
del zip
+
+ # Check author
+ if 'author' in dict(metadata):
+ if not re.match(r'^[^/]+$', dict(metadata)['author']):
+ raise ValidationError(_("Author name cannot contain slashes."))
+
# strip and check
checked_metadata = []
for k,v in metadata:
@@ -189,5 +196,7 @@ def validator(package):
checked_metadata.append((k, v))
except UnicodeDecodeError, e:
raise ValidationError(_("There was an error converting metadata '%s' to UTF-8 . Reported error was: %s") % (k, e))
+
+
return checked_metadata

0 comments on commit 7b252e5

Please sign in to comment.