Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`URI::FTP#normalize` returns incorrect (?) value if original path is empty

オープン
#185 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

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

調査の方向性

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

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

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

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

ruby/uri のほかの issue

ruby/uri の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

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

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