Skip to content

Allow leading underscore in sketch filenames #2105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2023
Merged

Allow leading underscore in sketch filenames #2105

merged 1 commit into from
Mar 13, 2023

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented Mar 13, 2023

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • [N/A] UPGRADING.md has been updated with a migration guide (for breaking changes)
  • [N/A] configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

Enhancement

What is the current behavior?

The Arduino Sketch Specification defines the allowed format of sketch folder names and sketch code filenames.

The origin of the specification is the text of the error message shown in Arduino IDE when the user attempts to save to a name that contains disallowed characters:

https://github.com/arduino/Arduino/blob/89539b1131f8cde9f7a83225f21c811071af53a8/app/src/processing/app/SketchController.java#L847-L853

However, the implementation of the restriction in the IDE codebase has a bug that allows a leading underscore (because the code uses _ as the replacement character).

After the restriction was implemented correctly in Arduino IDE 2.x, it was discovered that the loss of compatibility with these non-compliant names was impactful:

https://forum.arduino.cc/t/invalid-sketch-filename-dialog-when-opening-sketch-in-2-0-4/1096040

One of the primary purposes for the specification and restrictions is to ensure sketches can be used in any tool. Since the tools support this name format and there is no technical reason to disallow it, the best thing to do is change the sketch specification to follow the historic tool behavior (even if that behavior was unintended).

What is the new behavior?

Leading underscores in sketch folder names and sketch code filenames are permitted by the Arduino Sketch Specification and arduino-cli sketch new.

Does this PR introduce a breaking change, and is titled accordingly?

No breaking change (validation is made more permissive).

The Arduino Sketch Specification defines the allowed format of sketch folder names and sketch code filenames.

The origin of the specification is the text of the error message shown in Arduino IDE when the user attempts to save to
a name that contains disallowed characters:

https://github.com/arduino/Arduino/blob/89539b1131f8cde9f7a83225f21c811071af53a8/app/src/processing/app/SketchController.java#L847-L853

However, the implementation of the restriction in the IDE codebase has a bug that allows a leading underscore (because
the code uses _ as the replacement character).

After the restriction was implemented correctly in Arduino IDE 2.x, it was discovered that the loss of compatibility
with these non-compliant names was impactful.

One of the primary purposes for the specification and restrictions is to ensure sketches can be used in any tool. Since
the tools support this name format and there is no technical reason to disallow it, the best thing to do is change the
sketch specification to follow the historic tool behavior (even if that behavior was the result of a benign bug).

Leading underscores in sketch folder names and sketch code filenames are hereby permitted by the Arduino Sketch
Specification and `arduino-cli sketch new`.
@per1234 per1234 added type: enhancement Proposed improvement topic: documentation Related to documentation for the project topic: code Related to content of the project itself labels Mar 13, 2023
@per1234 per1234 self-assigned this Mar 13, 2023
@codecov
Copy link

codecov bot commented Mar 13, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.03 🎉

Comparison is base (fbeb271) 36.51% compared to head (0daef8a) 36.54%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2105      +/-   ##
==========================================
+ Coverage   36.51%   36.54%   +0.03%     
==========================================
  Files         229      229              
  Lines       19624    19624              
==========================================
+ Hits         7166     7172       +6     
+ Misses      11612    11608       -4     
+ Partials      846      844       -2     
Flag Coverage Δ
unit 36.54% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
commands/sketch/new.go 68.42% <100.00%> (ø)

... and 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@per1234 per1234 merged commit 7feb54f into arduino:master Mar 13, 2023
kittaakos pushed a commit to kittaakos/arduino-cli that referenced this pull request Mar 21, 2023
The Arduino Sketch Specification defines the allowed format of sketch folder names and sketch code filenames.

The origin of the specification is the text of the error message shown in Arduino IDE when the user attempts to save to
a name that contains disallowed characters:

https://github.com/arduino/Arduino/blob/89539b1131f8cde9f7a83225f21c811071af53a8/app/src/processing/app/SketchController.java#L847-L853

However, the implementation of the restriction in the IDE codebase has a bug that allows a leading underscore (because
the code uses _ as the replacement character).

After the restriction was implemented correctly in Arduino IDE 2.x, it was discovered that the loss of compatibility
with these non-compliant names was impactful.

One of the primary purposes for the specification and restrictions is to ensure sketches can be used in any tool. Since
the tools support this name format and there is no technical reason to disallow it, the best thing to do is change the
sketch specification to follow the historic tool behavior (even if that behavior was the result of a benign bug).

Leading underscores in sketch folder names and sketch code filenames are hereby permitted by the Arduino Sketch
Specification and `arduino-cli sketch new`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself topic: documentation Related to documentation for the project type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants