Running a cURL command to upload the contents of a file (by filling a form) like the following curl -L -X POST -F 'edit=filename' http://website.local/example -F 'filecontent=test;2;3'
will work on High Sierra but won't on Catalina
Catalina keeps stopping at the semicolon ;
and ignores the rest because it's interpreting the semicolon and outputs:
Warning: skip unknown form field: 2
Warning: skip unknown form field: 3
I've tried different things like escaping it \;
and single-quoting it but still no success, also tried changing to bash or different shells besides zsh.
Following the example curl -F 'colors="red; green; blue";type=text/x-myapp' example.com
works, I'm just trying to read the contents from a file now. The code that works on High Sierra is -F "filecontent=$(<Example.txt)"
The file I'm uploading contains semicolons and it uploads the text up until the first semicolon
curl 7.54.0 in High Sierra
curl 7.64.1 in Catalina
Change from --form
to --form-string
to prevent ;key=value
(as used for ;type=text/x-myapp
assignments) from being parsed.
Thus, you can change the pertinent line from:
curl "${other_args[@]}" -F "filecontent=$(<file)"
to:
curl "${other_args[@]}" --form-string "filecontent=$(<file)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With