Bug 478540

Summary: Can't edit form field after entering invalid character
Product: [Applications] okular Reporter: Tristan Miller <psychonaut>
Component: PDF backendAssignee: Okular developers <okular-devel>
Status: RESOLVED FIXED    
Severity: normal CC: oliver.sander, ppg.1382, psychonaut
Priority: NOR    
Version: 23.08.3   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Example PDF showing the bug

Description Tristan Miller 2023-12-15 09:57:47 UTC
Created attachment 164181 [details]
Example PDF showing the bug

Some PDF form fields require data in a certain format, and apply some sort of validation to enforce this requirement. A common example are fields requiring a telephone number. A problem with Okular is that if the user starts to type invalid data into such a field, it is no longer possible for the user to edit or delete the data.  I'm not sure if this is a problem with Okular itself (or its underlying PDF library) or with how the form designer implemented their field validation mechanism.  But even if it's the form designer's fault, it would be nice if Okular could provide some way of overriding the validation and allowing the user to delete the contents of the field.

This issue happens very often with forms that ask for a phone number and require only numeric data (but don't tell the user this on the form itself).  If one starts typing "+" as the prefix for the country code, the field refuses to accept any further input, and it's also not possible to remove the "+" using backspace, delete, undo, etc.  The only thing one can do is reload the form and start filling it in all over again.

STEPS TO REPRODUCE
1. Open the attached PDF.
2. Press the "Show Forms" button.
3. Click on the field for the home phone number.  This field expects a nine-digit phone number.
4. Type any character other than a digit, such as "+".

OBSERVED RESULT
5. At this point, the field largely stops responding to user input.  No further data can be typed.  Pressing backspace has no effect. The Undo command has no effect. Pressing the left cursor key puts the insertion point to the left of the +, but pressing delete has no effect.  The + can be selected with the mouse, but it cannot be deleted with backspace, delete, or the Cut command.

EXPECTED RESULT
5. Okular should allow the contents of the field to be edited, or at least the Undo command should reset the field to its previously blank state.

SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.27.9
KDE Frameworks Version: 5.112.0
Qt Version: 5.15.11
Comment 1 Oliver Sander 2024-01-03 09:37:49 UTC
Is this possibly a duplicate of https://bugs.kde.org/show_bug.cgi?id=474889 ?
Comment 2 Pratham Gandhi 2024-06-26 08:36:51 UTC
https://invent.kde.org/graphics/okular/-/merge_requests/1013 corrects the implementation of AFSpecial_Keystroke which restricts the user from entering invalid input.