`URI::FTP#normalize` returns incorrect (?) value if original path is empty
まだ誰も着手していません。
評価
調査の方向性
lib/uri/generic.rb の URI::Generic#normalize! と lib/uri/ftp.rb の URI::FTP#set_path から始め、リンクされた行を入口として使用してください。RFC 1738 を確認し、空のパスを持つ FTP URI の正規化に焦点を当てたテストを追加してください。完了とは、動作の方針が決まり、デフォルトディレクトリが誤って %2F としてエンコードされなくなることです。
索引モデルが issue の本文から書いたものです。
説明
I don't know how common this case is, but I did run into it accidentally while testing some code.
u = URI("ftp://ftp.example.com") # Note that there's no slash at the end
u.normalize.to_s # => "ftp://ftp.example.com/%2F"
I would expect the result to be "ftp://ftp.example.com/" or possibly the same as the original string, "ftp://ftp.example.com". As best as I can tell from RFC 1738, Section 3.2, "ftp://ftp.example.com" and "ftp://ftp.example.com/" are equivalent and refer to whatever the "default" directory is for FTP access, while "ftp://ftp.example.com/%2F" refers to the root directory.
This seems to be caused by a combination of two things. First, this code in URI::Generic#normalize!calls set_path('/') if the path is empty:
https://github.com/ruby/uri/blob/52077e9b07c555de6ad7ee74663b988fa38ca545/lib/uri/generic.rb#L1341-L1343
Second, URI::FTP overrides #set_path so that a leading slash in the argument is percent-encoded and appended to an unencoded slash: https://github.com/ruby/uri/blob/52077e9b07c555de6ad7ee74663b988fa38ca545/lib/uri/ftp.rb#L245-L247
I didn't see any tests for normalizing FTP URIs, so I'm not sure if this behavior is intended.
- 主要言語
- Ruby
- スター
- 125
- フォーク
- 65
- 平均マージ
- 6時間 4分
- マージ済み PR(30日)
- 2
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ruby/uri のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 25/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
riscv/riscv-unified-db#2626 ·
-
Component: GLib
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
ds-drift
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
we-promise/sure#3693 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
simp/pupmod-simp-simp#395 ·