mastodon.cardina1.red は、数々の独立したMastodonサーバーのうちのひとつです。サーバーに登録してFediverseのコミュニティに加わってみませんか。

サーバーの情報

3
人のアクティブユーザー

RFC 3986 Uniform Resource Identifier (IRI) において userinfo コンポーネント内の詳細な文法は規定されていなくてだいぶ雑なんだけど、 validator がどこまで検査するか悩ましい

RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
rfc-editor.org/rfc/rfc3986.htm

> userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
>
> Use of the format "user:password" in the userinfo field is deprecated.

www.rfc-editor.orgRFC 3986: Uniform Resource Identifier (URI): Generic Syntax

旧規格の RFC 2396 も言及がかなり微妙

RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax
rfc-editor.org/rfc/rfc2396#sec

> userinfo = *( unreserved | escaped |
> ";" | ":" | "&" | "=" | "+" | "$" | "," )
>
> Some URL schemes use the format "user:password" in the userinfo field.
> This practice is NOT RECOMMENDED, because (以下略)

www.rfc-editor.orgRFC 2396: Uniform Resource Identifiers (URI): Generic Syntax

RFC 1738: Uniform Resource Locators (URL)
rfc-editor.org/rfc/rfc1738#sec

> Within the user and password field, any ":", "@", or "/" must be encoded.

なるほどね?

www.rfc-editor.orgRFC 1738: Uniform Resource Locators (URL)
らりお・ザ・何らかの🈗然㊌ソムリエ

つまり何が問題かというと、 RFC 1738 時代の URL においては user:pass の user, pass 部分のコロンはエスケープすべしという明示があったんだけど、 RFC 2396 (URI), RFC 3986 (URI) においてはその旨の記述が消えておりコロンは何度でも出現できることになっている。
では、たとえば foo:bar:baz @ example.com のような URI を作ろうとしているとき validator および builder はどのように反応すべきか

RFC 3986 では以下のように言っており、 (まあ安全側に倒せば当然ではあるが) 最初のコロン以降は基本的に全部パスワード扱いしようということになっている

> Applications should not render as clear text any data after the first colon (":") character found within a userinfo subcomponent unless (以下略)

validator と safe serialization においては任意個のコロンを許容して最初のコロン以降全部パスワード扱いすればいいんだけど、 builder はどうすべきか

たとえばエスケープされていないコロンを慣習に沿っていないとして拒絶するのもアリだろうし、引数次第では自動エスケープするのも考えられなくはないし、あるいは user / password でそもそも区別して受け入れるべきではない (ユーザに userinfo を手動で合成させるべき) かもしれない