Skip to content

Creation of sketches with non-compliant names is permitted #1599

Closed
@per1234

Description

@per1234

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

  1. Select File > New from the Arduino IDE menus.
  2. Select File > Save As... from the Arduino IDE menus.
  3. Save the sketch under the sketchbook folder, with the name `~!@#$%^&()=+[{]};',
    🐛 The IDE allowed the creation of a sketch with non-compliant name.
  4. Click the ●●● icon on the right side of the editor toolbar.
  5. Select "New Tab" from the menu.
  6. In the "Name for new file" field, type `~!@#$%^&()=+[{]};',2
  7. Click the OK button.
    🐛 The IDE allowed the creation of an additional sketch file with non-compliant name.
  8. Select Tools > Board > Arduino AVR Boards > Arduino Uno from the Arduino IDE menus.
  9. 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
    
  10. Start Arduino IDE 1.x
    🐛 A warning dialog is shown on startup:
    image
    🐛 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.
  11. 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.
  12. 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:

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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions