changeset 328:76a3f40d163e

Make sure that the name entered for a build configuration doesn't contain spaces or other URL-unfriendly characters.
author cmlenz
date Tue, 10 Jan 2006 12:29:28 +0000
parents b0a77f62bb38
children f116a5068e4e
files ChangeLog bitten/trac_ext/tests/web_ui.py bitten/trac_ext/web_ui.py
diffstat 3 files changed, 27 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Version 0.5.1
+(10 January 2006, from 0.5.x branch)
+http://bitten.cmlenz.net/repos/bitten/tags/0.5.1
+
+ * Fixes compatibility with Trac 0.9.3 release, as well as the current trunk.
+ * Improves PostgreSQL compatibility.
+ * Fixes encoding of non-ASCII characters in command output.
+ * Fix for missing log output when using <java:ant> on Windows.
+
 Version 0.5
 (6 October 2005, from 0.5.x branch)
 http://bitten.cmlenz.net/repos/bitten/tags/0.5
--- a/bitten/trac_ext/tests/web_ui.py
+++ b/bitten/trac_ext/tests/web_ui.py
@@ -186,6 +186,18 @@
         assert module.match_request(req)
         self.assertRaises(TracError, module.process_request, req)
 
+    def test_new_config_submit_with_invalid_name(self):
+        PermissionSystem(self.env).grant_permission('joe', 'BUILD_ADMIN')
+        req = Mock(Request, method='POST', cgi_location='', path_info='/build',
+                   hdf=HDFWrapper(), perm=PermissionCache(self.env, 'joe'),
+                   args={'action': 'new', 'name': 'Foo bar',
+                         'path': 'test/trunk', 'label': 'Test',
+                         'description': 'Bla bla'})
+
+        module = BuildConfigController(self.env)
+        assert module.match_request(req)
+        self.assertRaises(TracError, module.process_request, req)
+
     def test_new_config_submit_invalid_path(self):
         PermissionSystem(self.env).grant_permission('joe', 'BUILD_ADMIN')
         req = Mock(Request, method='POST', cgi_location='', path_info='/build',
--- a/bitten/trac_ext/web_ui.py
+++ b/bitten/trac_ext/web_ui.py
@@ -232,8 +232,12 @@
         req.redirect(self.env.href.build(config.name))
 
     def _process_config(self, req, config):
-        if not req.args.get('name'):
+        name = req.args.get('name')
+        if not name:
             raise TracError('Missing required field "name"', 'Missing field')
+        if not re.match(r'^[\w.-]+$', name):
+            raise TracError('The field "name" may only contain letters, '
+                            'digits, periods, or dashes.', 'Invalid field')
 
         path = req.args.get('path', '')
         repos = self.env.get_repository(req.authname)
@@ -259,7 +263,7 @@
             except InvalidRecipeError, e:
                 raise TracError(e, 'Invalid recipe')
 
-        config.name = req.args.get('name')
+        config.name = name
         config.path = repos.normalize_path(path)
         config.recipe = recipe_xml
         config.min_rev = req.args.get('min_rev')
Copyright (C) 2012-2017 Edgewall Software