1

The following command works in GNU Bash on FreeBSD but not in Git Bash on Windows:

curl -X PUT https://example.com/_config/cors/origins -d '"*"'

The intended result is to send a PUT request to https://example.com/_config/cors/origins with the body "*" (including the quotes - it's a JSON string).

However on Windows, the asterisk gets expanded as a glob even though it’s within quotes. Excerpt from --trace-ascii cURL log:

0000: PUT /_config/cors/origins HTTP/1.1
004f: User-Agent: curl/7.30.0
008e: Content-Length: 13
00a2: Content-Type: application/x-www-form-urlencoded
00d3: 
=> Send data, 13 bytes (0xd)
0000: .editorconfig
== Info: upload completely sent off: 13 out of 13 bytes

(.editorconfig is the first file in the current directory.)

Escaping with a backslash ('"\*"') transmits the backslash:

0000: PUT /_config/cors/origins HTTP/1.1
004f: User-Agent: curl/7.30.0
008e: Content-Length: 4
00a1: Content-Type: application/x-www-form-urlencoded
00d2: 
=> Send data, 4 bytes (0x4)
0000: "\*"
== Info: upload completely sent off: 4 out of 4 bytes

Two backslashes also transmits both backslashes in the request.

0000: PUT /_config/cors/origins HTTP/1.1
004f: User-Agent: curl/7.30.0
008e: Content-Length: 5
00a1: Content-Type: application/x-www-form-urlencoded
00d2: 
=> Send data, 5 bytes (0x5)
0000: "\\*"
== Info: upload completely sent off: 5 out of 5 bytes

Is this a bug?

Tamlyn
  • 310

0 Answers0