Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

register_scheme does not comply with rfc2396 (or 3986) #89

Open
doriantaylor opened this issue Sep 12, 2023 · 3 comments · May be fixed by #148
Open

register_scheme does not comply with rfc2396 (or 3986) #89

doriantaylor opened this issue Sep 12, 2023 · 3 comments · May be fixed by #148

Comments

@doriantaylor
Copy link

doriantaylor commented Sep 12, 2023

RFC2396 § 3.1 states that the grammar for a URI scheme is:

      scheme        = alpha *( alpha | digit | "+" | "-" | "." )

whereas .register_scheme uses const_set and the grammar of Ruby constants is inconsistent with the grammar for a URI scheme:

  def self.register_scheme(scheme, klass)
    Schemes.const_set(scheme.to_s.upcase, klass)
  end

How much trouble would it be to switch to a Hash keyed by Symbols, so that it's possible to register (compliant) URI schemes with hyphens, + signs, dots?

@duerst
Copy link
Member

duerst commented Sep 12, 2023

How many schemes are there that actually use a '.'?

@doriantaylor
Copy link
Author

The answer is fourteen:

$ curl -s https://www.iana.org/assignments/uri-schemes/uri-schemes.txt | sed -n '/^\([a-z][^ ]*\)/ s/\([^[:space:]]*\).*/\1/ p' | grep '\.' | wc -l
$ 14

…along with five that contain a + and 81 that contain a -.

@nobu
Copy link
Member

nobu commented Jan 23, 2025

How much trouble would it be to switch to a Hash keyed by Symbols, so that it's possible to register (compliant) URI schemes with hyphens, + signs, dots?

A Hash was used to store schemes, and switched to constants for Ractor support in 2021.

nobu added a commit to nobu/uri that referenced this issue Jan 23, 2025
nobu added a commit to nobu/uri that referenced this issue Jan 23, 2025
@nobu nobu linked a pull request Jan 23, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants