From 054ae999dc5dfcb182f407bffceec5a52ae7ff6c Mon Sep 17 00:00:00 2001 From: Frank Schmitt Date: Tue, 15 Feb 2022 15:48:09 -0800 Subject: [PATCH] [ruby/uri] Update file.rb The module here is called `URI`, so it's probably reasonable to expect a requirement for the path to be RFC3986-compliant, but on the other hand, the class is called `File`, so it might be reasonable to expect that a path produced by e.g. the `File` class would be consumable by its `build` method (this fails if the filename contains e.g. a space). https://github.com/ruby/uri/commit/ef79789b83 --- lib/uri/file.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/uri/file.rb b/lib/uri/file.rb index 7671ad6470..4ff0bc097e 100644 --- a/lib/uri/file.rb +++ b/lib/uri/file.rb @@ -33,6 +33,9 @@ module URI # If an Array is used, the components must be passed in the # order [host, path]. # + # A path from e.g. the File class should be escaped before + # being passed. + # # Examples: # # require 'uri' @@ -44,6 +47,9 @@ module URI # :path => '/ruby/src'}) # uri2.to_s # => "file://host.example.com/ruby/src" # + # uri3 = URI::File.build({:path => URI::escape('/path/my file.txt')}) + # uri3.to_s # => "file:///path/my%20file.txt" + # def self.build(args) tmp = Util::make_components_hash(self, args) super(tmp)