Kong / Kong/httpsnippet

Generated multipart curl doesn't escape characters of form data fields

未关闭
#260 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
1.2k
派生
242
PR 合并指标
30 天内没有已合并 PR

描述

Related with https://github.com/Kong/insomnia/issues/3868

As of now we are not escaping double-quote characters that are in data fields of curl requests. This causes the curl request to fail.

Example generated curl:
```
curl --request GET \
--url http://mockbin.org/request/anything \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--form timestamp=2022-05-10T10:04:18.748Z \
--form field=test \
--form 'data=
TEST'
```

This doesn't seem to be the case for example for Python, where we escape characters we need to, and the request works fine:
```
import requests

url = "http://mockbin.org/request/anything"

payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"timestamp\"\r\n\r\n2022-05-10T10:07:25.650Z\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"field\"\r\n\r\ntest\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n\nTEST\r\n-----011000010111000001101001--\r\n"
headers = {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'}

response = requests.request("GET", url, data=payload, headers=headers)

print(response.text)
```

Example postman generated curl:
```
curl --location --request POST 'https://test.com' \
--form 'timestamp="2021-07-14T01:02:34.567Z"' \
--form 'field="test"' \
--form 'data="
TEST"'
```

贡献指南

打开贡献指南

调研方向

Start by locating the TypeScript code that generates multipart curl snippets and reproduce the shown XML field case. Update the generated form-data argument so embedded quote characters are escaped, then verify that the resulting curl request succeeds and add or update coverage if the repository has a relevant test.

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
tooling
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。