Summary: | KTimeComboBox may not allow valid time entry, depending on format (timeFormatToInputMask() too fragile) | ||
---|---|---|---|
Product: | [Frameworks and Libraries] frameworks-kwidgetsaddons | Reporter: | Philippe Cloutier <chealer> |
Component: | general | Assignee: | Christoph Feck <cfeck> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | kdelibs-bugs |
Priority: | NOR | ||
Version: | 5.60.0 | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | All | ||
See Also: | https://bugs.kde.org/show_bug.cgi?id=409912 | ||
Latest Commit: | https://invent.kde.org/frameworks/kwidgetsaddons/commit/37c9ebe699e33f84700489982da301bdf8727bd3 | Version Fixed In: | |
Sentry Crash Report: | |||
Attachments: | Screenshot of KOrganizer dialog with 2 affected fields |
Description
Philippe Cloutier
2019-07-16 17:09:05 UTC
Created attachment 121570 [details]
Screenshot of KOrganizer dialog with 2 affected fields
In this example, which shows a KOrganizer dialog in French Canadian, I demonstrated the bug by entering invalid times with a digit (above) and a letter (below) in a position supposed to contain a literal ("h").
This exceeds this ticket's scope, but there is another big problem with timeFormatToInputMask(): in 12-hour systems (such as en_US, using format "11:59 PM"), it does not require the AM or PM characters, since the special characters used in the mask are lowercase "a"-s. This allows users of such formats to enter incomplete times such as "10:00", which will be quietly "saved" as midnight. The special character for a mandatory letter is an *uppercase* "A". Ah, I forgot one point about the solution. I believe using the space character both as blank and as a literal part of the mask is bad. But except for using a different blank character (perhaps the underscore), I am not sure how that can be fixed with QLineEdit as it currently stands. Glen Ditchfield has proposed a very good-looking fix: https://invent.kde.org/frameworks/kwidgetsaddons/-/merge_requests/3 Git commit 37c9ebe699e33f84700489982da301bdf8727bd3 by Albert Astals Cid, on behalf of Glen Ditchfield. Committed on 02/07/2020 at 20:46. Pushed by aacid into branch 'master'. Fix KTimeComboBox for locales with unusual characters in formats KTimeComboBox creates an edit mask by replacing the AM/PM indicator in a formatted time with 'a' ("optional alphabetic") mask characters. This does not work for locales that use punctuation in the indicator, such as the current en_CA format "9:00 A.M.". This patch uses mask character 'x' ("optional non-blank"). The current fr_CA time format contains an embedded 'h': "9 h 00". 'h' is an edit mask character ("optional hexadecimal digit"), so the generated mask rejects properly-formatted times. This patch escapes all characters that are not supposed to be mask characters. Credit to Filipus Klutiero for a detailed explanation of the errors. ``` Related: bug 405857, bug 406240, bug 410167, bug 411820, bug 412506, bug 420468 ``` M +52 -3 autotests/ktimecomboboxtest.cpp M +5 -0 autotests/ktimecomboboxtest.h M +26 -23 src/ktimecombobox.cpp https://invent.kde.org/frameworks/kwidgetsaddons/commit/37c9ebe699e33f84700489982da301bdf8727bd3 |