Skip to content

Commit e3cf230

Browse files
committed
fix(ota): Wrap espota --auth flag in quotes
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% ```
1 parent 70786dc commit e3cf230

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: platform.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ tools.esptool_py.upload.network_pattern={network_cmd} -i "{serial.port}" -p "{ne
321321
tools.esp_ota.upload.protocol=network
322322
tools.esp_ota.upload.field.password=Password
323323
tools.esp_ota.upload.field.password.secret=true
324-
tools.esp_ota.upload.pattern={cmd} -i {upload.port.address} -p {upload.port.properties.port} --auth={upload.field.password} -f "{build.path}/{build.project_name}.bin"
324+
tools.esp_ota.upload.pattern={cmd} -i {upload.port.address} -p {upload.port.properties.port} "--auth={upload.field.password}" -f "{build.path}/{build.project_name}.bin"
325325

326326
## Upload Sketch Through DFU OTA
327327
## -------------------------------------------

0 commit comments

Comments
 (0)