# HG changeset patch # User cmlenz # Date 1136896168 0 # Node ID 76a3f40d163e4a82523cdea3eb37c3d910421d29 # Parent b0a77f62bb38091a27df4c2fe314c68d47c4e11d Make sure that the name entered for a build configuration doesn't contain spaces or other URL-unfriendly characters. diff --git a/ChangeLog b/ChangeLog --- 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 on Windows. + Version 0.5 (6 October 2005, from 0.5.x branch) http://bitten.cmlenz.net/repos/bitten/tags/0.5 diff --git a/bitten/trac_ext/tests/web_ui.py b/bitten/trac_ext/tests/web_ui.py --- 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', diff --git a/bitten/trac_ext/web_ui.py b/bitten/trac_ext/web_ui.py --- 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')