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

未关闭
#260 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

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

调研方向

首先定位生成 multipart curl 代码片段的 TypeScript 代码,并复现所示 XML 字段的大小写。更新生成的 form-data 参数,使其中嵌入的引号字符进行转义,然后验证生成的 curl 请求是否成功;如果 repository 中有相关测试,则添加或更新覆盖率。

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

描述

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=<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<test>TEST<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<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<test>TEST<test>\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="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<test>TEST<test>"'
主要语言
TypeScript
星标
1.2k
派生
242
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Kong/httpsnippet 的其他 Issue

查看 Kong/httpsnippet 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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