Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to keep a cURL command from interpreting a semicolon in macOS Catalina?

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

like image 262
Lex Lopez Avatar asked Oct 16 '19 19:10

Lex Lopez


1 Answers

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)"
like image 182
2 revs Avatar answered Nov 12 '22 18:11

2 revs