jd1378 / otphelper

open-source application that can copy OTP and codes from notifications automatically for you
GNU Affero General Public License v3.0
356 stars 31 forks source link

OTP for e-carte blue not recognised #51

Closed testcocoon closed 6 months ago

testcocoon commented 6 months ago

The following OTP from SMS are not recognised:

Le code à saisir pour votre achat de 200,00 EUR est 29444635. Ne donnez ce code à personne. Si vous n'avez pas réalisé cet achat, appelez le 09.69.32.00.04.

29444635 is the OTP.

jd1378 commented 6 months ago

sadly the first number appearing after "code" keyword is 200, which prevent the pattern from detecting the actual code

I can't change the pattern to fix this, as current requirement is that the first number after the sensitive keyword to be the code

testcocoon commented 6 months ago

You could extend the pattern to not consider the numbers followed by a currency symbol. Something like this regularly expression: code([a-z ]|([0-9.,] (EUR|USD))[0-9]

jd1378 commented 6 months ago

well I like the suggestion, but I can't execute it I invite you to help if you have the time try to make the required changes to the app's regex (without causing the tests to fail): https://regex101.com/r/ux6Kaz/1

jd1378 commented 6 months ago

part of the problem is that the app regex also takes a-zA-Z into account for codes, so it's not that simple

testcocoon commented 6 months ago

I will try to make a suggestion on regexp. I can then create a pull request. The only problem is that I cannot build your code. So I will validate the regex online and put it in the code directly. You will then need to review it.

testcocoon commented 6 months ago

I have added the following pattern: | ?[0-9,.]+ ?(EUR|[$€]|USD)

It ignores its number followed by EUR, USB $ or €. I have added it to the list of items to ignore. See the picture (part highlighted in yellow): Screenshot 2023-12-23 at 14-14-14 regex101 build test and debug regex (1)

jd1378 commented 6 months ago

sadly while it works in ecmascript version of the regex, it does not work in java adding the change breaks all cases, and it doesn't even detect the code in the case it is trying to solve

jd1378 commented 6 months ago

I'm still open to changing it if you did manage to find one that works and doesn't break other cases

jd1378 commented 6 months ago

well I managed to change the pattern to detect this as well