https://bugs.kde.org/show_bug.cgi?id=409867
Bug ID: 409867 Summary: KTimeComboBox may not allow valid time entry, depending on format (timeFormatToInputMask() too fragile) Product: frameworks-kwidgetsaddons Version: 5.60.0 Platform: Other OS: All Status: REPORTED Severity: normal Priority: NOR Component: general Assignee: cf...@kde.org Reporter: chea...@gmail.com CC: kdelibs-b...@kde.org Target Milestone: --- KTimeComboBox extends QLineEdit for time entry, using the inputMask property to set an input mask so users only need to type digits: https://doc.qt.io/qt-5/qlineedit.html#inputMask-prop Typically, it is used to enter a short time (hours and minutes only). Very often, the format is "23:59". For that, the simple input mask "09:99" works. Very often though, the format is more complicated. For example, "11:59 PM". Unfortunately, as can be seen in the Formats panel of systemsettings (in Regional parameters), there are numerous short time formats possible. As a result, rather than having a mapping of each possible format to each corresponding input mask, KTimeComboBox uses a rather complicated algorithm implemented in KTimeComboBoxPrivate::timeFormatToInputMask(). Unfortunately, that algorithm is fragile (in my book, it's a hack), as the "TODO" at the top acknowledges. Following the change of the fr_CA sublocale's short time format from the standard "23:59" to the much more particular "23 h 59", the generated input mask is "09 h 99", which is incorrect, since: 1. "h" is a special character for a position with a "Hexadecimal character permitted but not required". This position is therefore initialized to the blank character, which is " ". The field therefore has 7 characters, but on the third, "h" cannot be entered (only 0-9 and A-F). 2. If I understand correctly, the "blank character" being the space, all spaces are removed after input. This means the 3 consecutive spaces in the middle are removed, so if the field contains "12 34", the text value must be "1234", which is absolutely invalid. I am not entirely sure about this though, as the "11:59 PM" should also have a problem with the space, yet it works, and the documentation of QLineEdit's inputMask property is poor (I filed https://bugreports.qt.io/browse/QTBUG-77063 which requests improvement). One avenue to fix would be to change QLocale again and switch fr_CA back to "23:59", and this is under discussion: https://unicode-org.atlassian.net/browse/CLDR-8503 But this would only help fr_CA, and timeFormatToInputMask() should not be so sensitive in any case. On the KTimeComboBox side, as a minimum, a broken mask should never be returned. One way this could probably be achieved is by escaping all characters from the initial mask. For this to work, it would need to be verified that if a backslash precedes a non-special character in QLineEdit's inputMask, the backslash is just ignored. So for example, if we start from "12:34 PM", this would be escaped to "\1\2\:\3\4\ \P\M". But this would complicate the substitutions, which would need to replace escaped sequences (hours, minutes, seconds and AM/PM) by corresponding special characters. So for example, mask could evolve as follows: 12:34 PM \1\2\:\3\4\ \P\M 09\:\3\4\ \P\M 09\:99\ \P\M 09\:99\ aa This may cause issues with non-latin digits, but I must say that if the function is supposed to already support non-latin digits, I am not sure it does well. I am filing this at normal severity, but I will file a more severe report against incidenceeditor, as the combination of issues creates a severe symptom for KOrganizer. -- You are receiving this mail because: You are watching all bug changes.