Bug 452918

Summary: Payee > Account Numbers > IBAN does not accept pasted content with a space at the start
Product: [Applications] kmymoney Reporter: Duncan <kde.bugs>
Component: ux-uiAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 5.1.2   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.1.3
Sentry Crash Report:

Description Duncan 2022-04-23 17:52:03 UTC
SUMMARY
The IBAN and BIC fields in the per-payee Account Numbers does not accept pasted content from the clipboard on X11 if the content has whitespace at the beginning

STEPS TO REPRODUCE
1. Open Kate
2. Type an IBAN, placing an extra space at the start
3. Highlight the IBAN
4. Ctrl-C to copy the IBAN
5. Open kMyMoney
6. Choose a payee
7. Choose Account Numbers
8. Select IBAN & BIC
9. Double-click the IBAN & BIC that shows up to show the entry fields
10. Place cursor in IBAN field
11. Try to paste with Ctrl-V or Ctrl-Shift-Ins

OBSERVED RESULT
Paste does not happen

EXPECTED RESULT
One of

1. Acceptance of the pasted content, with the leading whitespace stripped.
2. An error dialog explaining why the content was not accepted.

Given the UI will reformat an IBAN of the format  IE48ICON11223344556677 into IE48 ICON 1122 3344 5566 77, I would advocate for the first option; apply strip() to the input, then validate that it's in the appropriate form for an IBAN. If it's still not appropriate, *tell* the person that it's not valid - don't silently fail.

SOFTWARE/OS VERSIONS
Operating System: Kubuntu 21.10
KDE Plasma Version: 5.24.4
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.2
Kernel Version: 5.13.0-40-generic (64-bit)
Graphics Platform: X11

ADDITIONAL INFORMATION
Comment 1 Duncan 2022-04-23 17:54:01 UTC
Where I ran into this was double-clicking an IBAN in wise.com's interface to select it, copying it with Ctrl-C, and then attempting to paste it. Something about the copied HTML places a space at each end of the text, and this whitespace is not obvious unless you paste into a program like Kate and notice the extra space on the highlight.
Comment 2 Duncan 2022-04-23 18:00:38 UTC
Clarity for step 3 of the reproduction - highlight including the space at the start.
Comment 3 Thomas Baumgart 2022-04-24 07:13:56 UTC
Git commit a5a3e9bb2560655212e63001dddb8ae886f87465 by Thomas Baumgart.
Committed on 24/04/2022 at 07:12.
Pushed by tbaumgart into branch 'master'.

Remove invalid chars from IBAN before validation check

The validation worked when single characters where added but it failed,
when text was pasted into the field and contained invalid chars. This
change removes those before the validation check is performed.

M  +1    -0    kmymoney/widgets/payeeidentifier/ibanbic/ibanvalidator.cpp

https://invent.kde.org/office/kmymoney/commit/a5a3e9bb2560655212e63001dddb8ae886f87465
Comment 4 Thomas Baumgart 2022-04-24 07:14:08 UTC
Git commit 99be6bdb11666d4ffa47fbab8b87449c8f4ed2b3 by Thomas Baumgart.
Committed on 24/04/2022 at 07:13.
Pushed by tbaumgart into branch '5.1'.

Remove invalid chars from IBAN before validation check

The validation worked when single characters where added but it failed,
when text was pasted into the field and contained invalid chars. This
change removes those before the validation check is performed.
FIXED-IN: 5.1.3

(cherry picked from commit a5a3e9bb2560655212e63001dddb8ae886f87465)

M  +1    -0    kmymoney/widgets/payeeidentifier/ibanbic/ibanvalidator.cpp

https://invent.kde.org/office/kmymoney/commit/99be6bdb11666d4ffa47fbab8b87449c8f4ed2b3
Comment 5 Duncan 2022-04-24 07:34:24 UTC
Thank you Thomas. I had looked in that validator code, but my C++ knowledge is about zero, so couldn't offer a patch (and didn't know fixup() existed either).