fix: escape $ in curl request bodies and headers (#6245)

This address a bug where a `$` character in a request body or header
would not be properly escaped in a string in the generated curl command.

Fixes #5390
This commit is contained in:
Alec Theriault
2020-08-03 12:07:06 -04:00
committed by GitHub
parent 28b3b4c4b6
commit 225a915cf8
2 changed files with 15 additions and 2 deletions

View File

@@ -319,4 +319,17 @@ describe("curlify", function () {
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"x-custom-name: multipart/form-data\" -d {\"id\":\"123\",\"file\":{\"name\":\"file.txt\",\"type\":\"text/plain\"}}")
})
})
it("should escape dollar signs in headers and request body", function () {
let req = {
url: "http://example.com",
method: "POST",
headers: { "X-DOLLAR": "token/123$" },
body: "CREATE ($props)"
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"X-DOLLAR: token/123\\$\" -d \"CREATE (\\$props)\"")
})
})