From 0746942e0278465bb1f8dbaeb10f2eeb51dcd57c Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Sun, 14 Nov 2010 22:18:56 +0100 Subject: [PATCH] accept backends name with only letters and digits --- weboob/tools/application/qt/backendcfg.py | 6 ++++++ weboob/tools/application/repl.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/weboob/tools/application/qt/backendcfg.py b/weboob/tools/application/qt/backendcfg.py index 416fa211..b4008859 100644 --- a/weboob/tools/application/qt/backendcfg.py +++ b/weboob/tools/application/qt/backendcfg.py @@ -21,6 +21,7 @@ from PyQt4.QtGui import QDialog, QTreeWidgetItem, QLabel, QFormLayout, \ QDialogButtonBox from PyQt4.QtCore import SIGNAL, Qt, QVariant, QUrl +import re from logging import warning from weboob.capabilities.account import ICapAccount, Account, AccountRegisterError @@ -206,6 +207,11 @@ class BackendCfg(QDialog): self.tr('Please specify a backend name')) return + if self.ui.nameEdit.isEnabled() and not re.match(r'^[\w\-_]+$', bname): + QMessageBox.critical(self, self.tr('Invalid value'), + self.tr('The backend name can only contain letters and digits')) + return + if self.ui.proxyBox.isChecked(): params['_proxy'] = unicode(self.ui.proxyEdit.text()) if not params['_proxy']: diff --git a/weboob/tools/application/repl.py b/weboob/tools/application/repl.py index e0632d87..6826ca84 100644 --- a/weboob/tools/application/repl.py +++ b/weboob/tools/application/repl.py @@ -241,7 +241,7 @@ class ReplApplication(Cmd, BaseApplication): except BackendAlreadyExists: print 'Backend "%s" is already configured in file "%s"' % (name, self.weboob.backends_config.confpath) while self.ask('Add new instance of "%s" backend?' % name, default=False): - new_name = self.ask('Please give new instance name (could be "%s_1")' % name, regexp=u'^[\d\w_-]+$') + new_name = self.ask('Please give new instance name (could be "%s_1")' % name, regexp=r'^[\w\-_]+$') try: self.weboob.backends_config.add_backend(new_name, name, params) print 'Backend "%s" successfully added.' % new_name