Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ota): Wrap espota --auth flag in quotes (#10126)
When performing an "OTA" upload via a network port, the user may configure the sketch to require an authentication password. Arduino IDE presents a "Configure and Upload" dialog when the user triggers an upload to a network port. The user can provide the authentication password via the field in that dialog. The `upload.field.password` platform property is then set to the value provided by the user. The platform uses the `tools.esp_ota.upload.pattern` command template to pass this value to the espota upload tool via the tool's `--auth` flag. Since the value of the `upload.field.password` platform property is set by the user via a free text field, it might contain any characters. Since some characters (e.g., spaces) can be problematic in a command line, it is essential to wrap it in quotes. This was done for the Arduino IDE 1.x variant of the command template, but that was not ported when the pluggable discovery variant of the command pattern was defined. This causes a spurious failure of the OTA upload process if the user provides an authentication password that contains problematic characters. For example: ``` "C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\tools\espota.exe" \ -r -i 192.168.254.145 \ -p 3232 --auth=foo bar \ -f "C:\Users\per\AppData\Local\Temp\arduino\sketches\E2D807FABB134A2A60A1B9C7D14FE02B/11973.ino.bin" usage: espota.exe [-h] [-i ESP_IP] [-I HOST_IP] [-p ESP_PORT] [-P HOST_PORT] [-a AUTH] [-f FILE] [-s] [-d] [-r] [-t TIMEOUT] espota.exe: error: unrecognized arguments: bar Failed uploading: uploading error: exit status 2 ``` This is prevented by wrapping the `--auth` flag in quotes: ``` "C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\tools\espota.exe" \ a-r -i 192.168.254.145 \ -p 3232 "--auth=foo bar" \ -f "C:\Users\per\AppData\Local\Temp\arduino\sketches\E2D807FABB134A2A60A1B9C7D14FE02B/11973.ino.bin" Sending invitation to 192.168.254.145 Authenticating...OK Uploading: [ ] 0% ```
- Loading branch information