Bug #3594


URI class doesn't do file URL's properly.

Added by NeilW (Neil Wilson) over 12 years ago. Updated about 5 years ago.

Target version:
ruby -v:
ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]


URI doesn't seem to output file URLs properly where there is an absolute path part.

For example.

require 'uri'

my_url = URI.parse("file:///var/lib/libvirt/images/")
p my_url.to_s


The double slash '//' should always appear according to the file URL specification.

Actions #1

Updated by akr (Akira Tanaka) over 11 years ago

  • Project changed from Ruby to Ruby master
  • Assignee set to akira (akira yamada)
Actions #2

Updated by shyouhei (Shyouhei Urabe) over 10 years ago

  • Status changed from Open to Assigned

Updated by mame (Yusuke Endoh) almost 10 years ago

  • Description updated (diff)

Is this specified in RFC or any spec?

Yusuke Endoh

Updated by naruse (Yui NARUSE) almost 10 years ago

mame (Yusuke Endoh) wrote:

Is this specified in RFC or any spec?

There's no available RFC of file URI scheme.

see also:

Updated by mame (Yusuke Endoh) about 5 years ago

RFC 8089 (The "file" URI Scheme) has been published in 2017. It says:

      file-URI       = file-scheme ":" file-hier-part

      file-scheme    = "file"

      file-hier-part = ( "//" auth-path )
                     / local-path

      auth-path      = [ file-auth ] path-absolute

      local-path     = path-absolute

and RFC 3986 says:

      path-absolute = "/" [ segment-nz *( "/" segment ) ]

So, "file:/var/lib/libvirt/images/" does not conform the spec, I think.

The maintainer of lib/uri.rb is Akira Yamada, who seems inactive. Does anyone want to investigate and fix this issue?

Updated by mame (Yusuke Endoh) about 5 years ago

  • Status changed from Assigned to Rejected

Sorry, I misread the spec. The URI is valid because it can be interpreted as file-scheme ":" local-path. So, there is no problem. Closing.

Updated by naruse (Yui NARUSE) about 5 years ago

  • Status changed from Rejected to Closed

I found the description in URL spec.
Therefore I fixed it at r60970.


Also available in: Atom PDF