Project

General

Profile

Feature #14035

URI module always serializes to the minimal form insted of the traditional one

Added by ioggstream (Roberto Polli) over 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:83423]

Description

Reproduce

execute URI("file:///etc/hosts").to_s

I expect

I wish

  • URI to preserve the minimal/traditional form.

URI("file:///etc/hosts").to_s == "file:///etc/hosts"
URI("file:/etc/hosts").to_s == "file:/etc/hosts"

Instead

  • URI("file:///etc/hosts").to_s == "file:/etc/hosts"

  • URI("file:///etc/hosts").host == nil

Proposal for Ruby 2.4

Adopting the convention of an "empty host" instead of no authority when the passed string has the traditional form.

  • file schema to have a blank/empty "" host

suggested in rfc3986 will fix the issue.

   If the URI scheme defines a default for host, then that default
   applies when the host subcomponent is undefined or when the
   registered name is empty (zero length).  For example, the "file" URI
   scheme is defined so that no authority, an empty host, and
   "localhost" all mean the end-user's machine, whereas the "http"
   scheme considers a missing authority or empty host invalid.

Associated revisions

Revision 04883f12
Added by naruse (Yui NARUSE) about 1 year ago

Introduce URI::File to handle file URI scheme

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 62767
Added by naruse (Yui NARUSE) about 1 year ago

Introduce URI::File to handle file URI scheme

Revision 62767
Added by naruse (Yui NARUSE) about 1 year ago

Introduce URI::File to handle file URI scheme

History

#1

Updated by ioggstream (Roberto Polli) over 1 year ago

  • Subject changed from URI module file representation does not conform to the standard to URI module file representation uses the minimal form instead of the traditional one.

Updated by phluid61 (Matthew Kerwin) over 1 year ago

The spec for file URIs is RFC8089, which allows for file URIs with no authority part (e.g. 'file:/foo').

Neither it nor RFC3986 make any claims about canonical representation of URIs, much as I may have liked it to.

Also, have a look at the 'file-uri' gem.

#3

Updated by ioggstream (Roberto Polli) over 1 year ago

  • Backport deleted (2.3: UNKNOWN, 2.4: UNKNOWN)
  • ruby -v deleted (ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux])
  • Description updated (diff)
  • Subject changed from URI module file representation uses the minimal form instead of the traditional one. to URI module always serializes to the minimal form insted of the traditional one
  • Tracker changed from Bug to Feature

Updated by ioggstream (Roberto Polli) over 1 year ago

Hi Matthew, and thanks for your time!

phluid61 (Matthew Kerwin) wrote:

The spec for file URIs is RFC8089, which allows for file URIs with no authority part (e.g. 'file:/foo').

Ok.

Neither it nor RFC3986 make any claims about canonical representation of URIs, much as I may have liked it to.

I read here https://tools.ietf.org/html/rfc8089#appendix-B reports that there is a traditional form though.
Clearly traditional != canonical ;)

Checked gem, thx++

#5

Updated by naruse (Yui NARUSE) about 1 year ago

  • Status changed from Open to Closed

Applied in changeset trunk|r62767.


Introduce URI::File to handle file URI scheme

Also available in: Atom PDF