From d1f7d6f6acd6e66e2c139c3e51bbc38ee71cd192 Mon Sep 17 00:00:00 2001 From: Guillaume Risbourg Date: Fri, 15 May 2020 11:19:01 +0200 Subject: [PATCH] [axabanque] Add regex to check for invalid character in new recipients label The website doesn't accept special chars in the recipient label. --- modules/axabanque/module.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/axabanque/module.py b/modules/axabanque/module.py index fd9200f8ff..4992a79c63 100644 --- a/modules/axabanque/module.py +++ b/modules/axabanque/module.py @@ -19,8 +19,13 @@ from __future__ import unicode_literals +import re + from weboob.capabilities.base import find_object, empty -from weboob.capabilities.bank import Account, TransferInvalidLabel, CapBankTransferAddRecipient, AccountNotFound, RecipientNotFound +from weboob.capabilities.bank import ( + Account, TransferInvalidLabel, CapBankTransferAddRecipient, AccountNotFound, + RecipientNotFound, RecipientInvalidLabel, +) from weboob.capabilities.wealth import CapBankWealth from weboob.capabilities.profile import CapProfile from weboob.capabilities.bill import CapDocument, Subscription, Document, DocumentNotFound, SubscriptionNotFound @@ -78,6 +83,14 @@ def iter_transfer_recipients(self, origin_account): def new_recipient(self, recipient, **params): recipient.label = recipient.label[:24].upper() + + if not re.match(r"^[A-Z0-9/?:()\.,'+ ]+$", recipient.label): + # This check is done here instead of checking the error return on the pages + # because this appears after the sms otp. This allow the user to know that + # the label is incorrect before having to enter an otp. + # The message in the error is the exact one that is displayed on the website. + raise RecipientInvalidLabel("Les caractères autorisés sont l'alphabet latin, les chiffres et les caractères / - ? : ( ) . , ' + ESPACE") + return self.browser.new_recipient(recipient, **params) def init_transfer(self, transfer, **params): -- GitLab