FILTER_VALIDATE_URL returns false when underscore present in URL
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
The following code:
<?php
var_dump(filter_var('https://sub_domain.example.com', FILTER_VALIDATE_URL));
var_dump(filter_var('https://ex_ample.com', FILTER_VALIDATE_URL));
Resulted in this output:
bool(false)
bool(false)
But I expected this output instead:
string(30) "https://sub_domain.example.com"
string(20) "https://ex_ample.com"
The underscore is a valid character according to the RFC 2396 section 2.3:
Unreserved Characters
Data characters that are allowed in a URI but do not have a reserved
purpose are called unreserved. These include upper and lower case
letters, decimal digits, and a limited set of punctuation marks and
symbols.unreserved = alphanum | mark mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"Unreserved characters can be escaped without changing the semantics
of the URI, but this should not be done unless the URI is being used
in a context that does not allow the unescaped character to appear.
But this filter fails if a underscore is present in the domain or subdomain portion of the URL.
This RFC is superseded by RFC 3986, but the underscore is still in the unreserved characters:
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
PHP Version
PHP 8.4.4
Operating System
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、Issue に示されている FILTER_VALIDATE_URL を指定した filter_var() の呼び出しを再現し、その後 php-src にある URL 検証の実装を追ってください。ホストおよびサブドメインの各コンポーネントにおけるアンダースコアの扱いを、引用されている RFC のセクションと比較してください。文書化された例が期待される検証結果を生成し、関連するテストでこの挙動がカバーされれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100