Improper location decoding
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 32/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- typescript
調査の方向性
ファイルもテストも名前が指定されていません。まず、ルートマッチングと、location から decodeURI を呼び出しているすべての箇所を追跡し、その後、issue にある encoded-slash と percent の例を再現します。完了条件は、ルートパラメーターがエンコードされた区切り文字を保持し、その後のデコードが URI エラーなしに曖昧さなく行えることです。これらのケースに対する焦点を絞った回帰テストカバレッジを追加してください。
索引モデルが issue の本文から書いたものです。
説明
As of wouter 3.x, the library now calls decodeURI on locations during route matching, meaning route parameters have had this called on them as well. I'm not quite sure why this was added, as it doesn't match how routing would work in a typical HTTP server. That is, if I hit:
GET /path/escaped%2Fslashes
the intent is that this %2F is not treated like a slash, so if we were serving e.g. directories of files, this would look for a file named escaped%2Fslashes in the directory path, not a directory named escaped containing a file named slashes.
This presents a problem that is not solvable for clients of this library if any of their route components can contain a certain collection of characters. You can end up with a parameter value that can no longer be decoded unambiguously.
For instance, if you allow parameters that contain a % and #, you must use encodeURIComponent on this parameter or the resulting location will not work properly, but decodeURI will partially decode this string and you can no longer determine what the original string was without parsing (and effectively doing the routing) yourself:
const url = '/' + encodeURIComponent(`foo/bar#baz%`) // 'foo%2Fbar%23baz%25'
const afterWouter = decodeURI(url) // '/foo/bar%23baz%'
const laterDecode = decodeURIComponent(afterWouter) // throws "URIError: URI malformed"
Since the original string could also contain e.g. %25 at the end, the string at afterWouter is now ambiguous as well: we cannot tell whether the original string contained % or %25 unless we go back and look at the location value, and decoding multiple times may actually "work" without throwing an error but give you a value that is not the same as the original.
Calling decodeURI on the entire URL string multiple times makes issues like this impossible to fix, and wouter at this point seems to do it quite often.
- 主要言語
- TypeScript
- スター
- 7.9k
- フォーク
- 193
- 平均マージ
- 9分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
molefrog/wouter のほかの issue
-
Wouter double-decodes search params in `useSearchParams`, which can lead to �対応中かも @priyas1672 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
Links using ~ do not respect `base`対応中かも @molefrog が 25 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
molefrog/wouter の issue をすべて見る
似ている issue
-
Replace discontinued crypto-js in the theme対応中かも @aelmanaa が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
PaloAltoNetworks/docusaurus-openapi-docs#1689 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
solana-foundation/solana-web3.js#4015 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 1/5 1〜3時間 初心者へのやさしさ 90/100
ivopogace/opencode-courier#422 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
chapel-lang/chapel-vscode#158 ·
メンテナーはふだん 1 日以内に返信