Improve detection of #include
directives for arduino_secrets.h
#447
Labels
topic: cloud
Related to Arduino Cloud and cloud sketches
topic: code
Related to content of the project itself
type: imperfection
Perceived defect in any part of project
Describe the bug
Arduino Web Editor has a "Secret tab" feature that makes it easy to share sketches without accidentally exposing sensitive data (e.g., passwords or tokens).
The values of these secrets can be defined on Arduino Cloud via a form in the "Secret" tab in Arduino Web Editor.
On Arduino Cloud, secrets are stored in a secure database and the secret macro values populated from there.
The secrets database capability is not available when using the Arduino IDE, so a more conventional approach is taken by defining the secrets macros in a header file named
arduino_secrets.h
. In order to allow the use of the macros from this file, it's necessary to add an #include directive at the top of the primary sketch file forarduino_secrets.h
(#438) when it is pulled. Before pushing, the#include
directive should be removed.Arduino Language syntax allows for an arbitrary number of spaces within an
#include
directive at two locations:#
and theinclude
identifier.include
identifier and the header file path.The regular expression used by the Arduino IDE to find and remove this code:
https://github.com/arduino/arduino-ide/blob/2.0.0-beta.9/arduino-ide-extension/src/browser/create/create-api.ts#L247-L248
🐛 Does not currently accommodate any variation in the number of spaces.
🐛 In addition, it will match to incidental occurrences of this string which are not valid syntax.
To Reproduce
🐛 You will now have this:
🐛 You will also have this line in the sketch when opened in Arduino Cloud:
🐛 You will now have this:
// the purpose of #include "arduino_secrets.h" is to provide the secrets
🐛 You will now have this:
// the purpose of is to provide the secrets
Expected behavior
Any valid form of
#include
directive forarduino_secrets.h
to be recognized.Occurrences of
#include "arduino_secrets.h"
in comments to be left alone.Screenshots
If applicable, add screenshots to help explain your problem.
Desktop
Date: 2021-07-08T14:42:27.433Z
CLI Version: 0.18.3 alpha [d710b642]
The text was updated successfully, but these errors were encountered: