From 144ff9a61a4b368f72aac7948f7b458d37b230f7 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 21 Apr 2017 14:02:58 +0200 Subject: Revert "[FIX] web: refuse DB name with space" This is too restrictive. This reverts commit 606712a5d2881de91525275d78e574660301461a. --- addons/web/controllers/main.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 6176bafe89f..cc62a287aca 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -651,8 +651,6 @@ class Database(http.Controller): @http.route('/web/database/create', type='http', auth="none", methods=['POST'], csrf=False) def create(self, master_pwd, name, lang, password, **post): try: - if not re.match('^[a-zA-Z][a-zA-Z0-9_]+$', name): - raise Exception(_('Invalid database name. Only alphanumerical characters and underscore are allowed.')) # country code could be = "False" which is actually True in python country_code = post.get('country_code') or False request.session.proxy("db").create_database(master_pwd, name, bool(post.get('demo')), lang, password, post['login'], country_code) @@ -665,8 +663,6 @@ class Database(http.Controller): @http.route('/web/database/duplicate', type='http', auth="none", methods=['POST'], csrf=False) def duplicate(self, master_pwd, name, new_name): try: - if not re.match('^[a-zA-Z][a-zA-Z0-9_]+$', new_name): - raise Exception(_('Invalid database name. Only alphanumerical characters and underscore are allowed.')) request.session.proxy("db").duplicate_database(master_pwd, name, new_name) return http.local_redirect('/web/database/manager') except Exception, e: -- cgit v1.2.3 From 9e6860a22808a114a2f745e4bfd288e08460151b Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 21 Apr 2017 15:23:17 +0200 Subject: [FIX] web: make DB name more flexible --- addons/web/controllers/main.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'addons/web/controllers/main.py') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index cc62a287aca..3dc9d4526bc 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -52,6 +52,8 @@ env.filters["json"] = json.dumps # 1 week cache for asset bundles as advised by Google Page Speed BUNDLE_MAXAGE = 60 * 60 * 24 * 7 +DBNAME_PATTERN = '^[a-zA-Z0-9][a-zA-Z0-9_.-]+$' + #---------------------------------------------------------- # OpenERP Web helpers #---------------------------------------------------------- @@ -630,6 +632,7 @@ class Database(http.Controller): d['list_db'] = openerp.tools.config['list_db'] d['langs'] = openerp.service.db.exp_list_lang() d['countries'] = openerp.service.db.exp_list_countries() + d['pattern'] = DBNAME_PATTERN # databases list d['databases'] = [] try: @@ -651,6 +654,8 @@ class Database(http.Controller): @http.route('/web/database/create', type='http', auth="none", methods=['POST'], csrf=False) def create(self, master_pwd, name, lang, password, **post): try: + if not re.match(DBNAME_PATTERN, name): + raise Exception(_('Invalid database name. Only alphanumerical characters, underscore, hyphen and dot are allowed.')) # country code could be = "False" which is actually True in python country_code = post.get('country_code') or False request.session.proxy("db").create_database(master_pwd, name, bool(post.get('demo')), lang, password, post['login'], country_code) @@ -663,6 +668,8 @@ class Database(http.Controller): @http.route('/web/database/duplicate', type='http', auth="none", methods=['POST'], csrf=False) def duplicate(self, master_pwd, name, new_name): try: + if not re.match(DBNAME_PATTERN, new_name): + raise Exception(_('Invalid database name. Only alphanumerical characters, underscore, hyphen and dot are allowed.')) request.session.proxy("db").duplicate_database(master_pwd, name, new_name) return http.local_redirect('/web/database/manager') except Exception, e: -- cgit v1.2.3