Kong / Kong/httpsnippet

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

オープン
#260 コメント 2 件 リアクション 0 件 担当者 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=<?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>"'

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、multipart の curl スニペットを生成する TypeScript コードを見つけ、表示されている XML フィールドの大文字・小文字を再現します。生成された form-data 引数を更新して、埋め込まれた引用符文字がエスケープされるようにし、その後、結果の curl リクエストが成功することを確認します。リポジトリに関連するテストがある場合は、カバレッジを追加または更新します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。