Closed
Description
Describe the problem
The Arduino sketch specification defines the characters allowed for use in sketch folder and file names:
https://arduino.github.io/arduino-cli/dev/sketch-specification/#sketch-folders-and-files
🐛 Arduino IDE allows users to create sketches with non-compliant names
To reproduce
- Select File > New from the Arduino IDE menus.
- Select File > Save As... from the Arduino IDE menus.
- Save the sketch under the sketchbook folder, with the name
`~!@#$%^&()=+[{]};',
🐛 The IDE allowed the creation of a sketch with non-compliant name. - Click the ●●● icon on the right side of the editor toolbar.
- Select "New Tab" from the menu.
- In the "Name for new file" field, type
`~!@#$%^&()=+[{]};',2
- Click the OK button.
🐛 The IDE allowed the creation of an additional sketch file with non-compliant name. - Select Tools > Board > Arduino AVR Boards > Arduino Uno from the Arduino IDE menus.
- Select Sketch > Verify/Compile from the Arduino IDE menus.
🐛 Compilation fails with a cryptic error:avr-g++: error: C:\Users\per\AppData\Local\Temp\arduino-sketch-DC0B853C212DB0BA0ED269B37923BDC7\sketch\`~!@#$%^&()=+[;',.ino.cpp: No such file or directory avr-g++: warning: '-x c++' after last input file has no effect avr-g++: fatal error: no input files compilation terminated. exit status 1 Compilation error: exit status 1
- Start Arduino IDE 1.x
🐛 A warning dialog is shown on startup:
🐛 The sketch can not be shared with Arduino IDE 1.x users due to the non-compliant name.
This problem seems less significant in this contrived demo where the sketch name causes compilation failure, but other non-compliant sketch names will not have an obvious impact to the Arduino IDE 2.x user. - Import the sketch to Arduino Web Editor
⚠ Due to a bug in Arduino Web Editor, the sketch will be impossible to delete and might possibly cause other problems, so I don't recommend actually doing this with any Arduino account you care about.
🐛 There is an error message on import. - Delete the imported sketch from your Arduino Web Editor sketchbook.
🐛 The sketch is impossible to delete:Error while deleting `~!@#$%^&()=+[{]};',
🐛 Arduino IDE 2.x allows the creation of sketches that are either unusable or not portable to other official development software.
Expected behavior
Arduino IDE 2.x does not allow the creation of sketches with non-compliant names.
Sketches created with one development tool are usable in all other tools.
Arduino IDE version
2.0.1
Operating system
- Windows
- Linux
Operating system version
- Windows 10
- Ubuntu 20.04
Additional context
Originally reported by @UKHeliBob at https://forum.arduino.cc/t/file-save-as-allows-invalid-filenames-to-be-used/700966
Related:
- https://forum.arduino.cc/t/sketch-with-bad-name/1072114
- https://forum.arduino.cc/t/ide-2-0-4-on-win10-shows-no-ports-for-digispark-usb/1083255/17
- https://forum.arduino.cc/t/project-breaks-anytime-i-save-file/1076804
- https://forum.arduino.cc/t/mac-m1-studio-arduino-2-0-3/1063497/1
- https://forum.arduino.cc/t/mac-m1-studio-arduino-2-0-3/1063497/4
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