Bug 454778 - The regexp check for shortcuts MnemonicData detection is not sufficient
Summary: The regexp check for shortcuts MnemonicData detection is not sufficient
Status: ASSIGNED
Alias: None
Product: frameworks-qqc2-desktop-style
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Marco Martin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-02 22:13 UTC by ratijas
Modified: 2023-02-27 02:24 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ratijas 2022-06-02 22:13:28 UTC
SUMMARY
This code is problematic:

    Shortcut {
        //in case of explicit & the button manages it by itself
        enabled: !(RegExp(/\&[^\&]/).test(controlRoot.text))

It does not handle even what it's directly supposed to: an ampersand but not a double ampersand.
This snippet is duplicated across several controls. It should be fixed by rewriting into native (C++) code.

STEPS TO REPRODUCE
1. console.log(!(RegExp(/\&[^\&]/).test("Yaha && ha!")))

OBSERVED RESULT
false

EXPECTED RESULT
true

ADDITIONAL INFORMATION
Affected components are:

- Button.qml
- CheckBox.qml
- MenuBarItem.qml
- MenuItem.qml
- RadioButton.qml
- Switch.qml
- TabButton.qml
- ToolButton.qml
Comment 1 Bug Janitor Service 2023-02-27 02:24:36 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/qqc2-desktop-style/-/merge_requests/241