Description
Describe the problem
The File > Sketchbook menu provides convenient access to the sketches the user has stored under their sketchbook folder.
During the population of this menu, the IDE processes each sketch name as a regular expression:
🐛 If a sketch with a name that happens to be an invalid regular expression is present in the sketchbook, the File > Sketchbook menu is missing.
To reproduce
- Select File > Save As... from the Arduino IDE menus.
- Save the sketch under the sketchbook folder with the name
Foo
- Select File > Sketchbook from the Arduino IDE menus.
🙂 The "Foo" sketch and any other sketches present in the sketchbook are listed in the menu. - Select File > Save As... from the Arduino IDE menus.
- Save the sketch under the sketchbook folder with the name
Bar++
- Select File from the Arduino IDE menus.
🐛 There is no File > Sketchbook menu.
Expected behavior
File > Sketchbook menu is populated with all valid sketches even if invalid sketches are also present in the sketchbook.
Arduino IDE version
2.0.1
Operating system
- Windows
- Linux
Operating system version
- Windows 10
- Ubuntu 20.04
Additional context
This issue is not about supporting non-compliant sketch names. I used File > Save As... in the demo in order to make it as simple as possible to reproduce this bug. However, even after the bug of the IDE allowing the creation of non-compliant sketch names (#1599) is fixed, the user may still create or find such sketches (which will become increasingly prevalent since the IDE allows their creation) in the wild. The IDE must handle the presence of such invalid sketches gracefully, rather than breaking.
One option for resolving the issue would be to escape the sketchName
string for use in a regular expression, as done here:
https://stackoverflow.com/a/6969486/7059512
I bisected the introduction of the bug to 4c55807 / #1018 (does not occur with the build for cb50d3a)
Originally reported by @Willem43T at https://forum.arduino.cc/t/2-0-1-no-open-recent-menu-item/1046905/6
Issue checklist
- I searched for previous reports in the issue tracker
- I verified the problem still occurs when using the latest nightly build
- My report contains all necessary details