commit d2a2a0d7544237a29bf932773cc85e9050bd9c26
parent 4e7b5c9a0fedeece3adeaecf79ec2088082c5fbc
Author: Dan Callaghan <djc@djc.id.au>
Date: Wed, 29 Mar 2023 21:37:16 +1100
treat empty URI#host the same as nil
Since Ruby 3.2, the URI#host method returns empty string rather than nil
if the URI does not have a host component (like maildir:///blah).
Apparently for some kind of security reasons, see:
https://github.com/ruby/ruby/commit/dd5118f8524c425894d4716b787837ad7380bb0d
Diffstat:
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb
@@ -369,7 +369,7 @@ EOS
def retrieve fingerprint
require 'net/http'
uri = URI($config[:keyserver_url] || KEYSERVER_URL)
- unless uri.scheme == "http" and not uri.host.nil?
+ unless uri.scheme == "http" and not uri.host.nil? and not uri.host.empty?
return "Invalid url: #{uri}"
end
diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
@@ -23,7 +23,7 @@ class Maildir < Source
end
raise ArgumentError, "not a maildir URI" unless uri.scheme == "maildir"
- raise ArgumentError, "maildir URI cannot have a host: #{uri.host}" if uri.host
+ raise ArgumentError, "maildir URI cannot have a host: #{uri.host}" unless uri.host.nil? || uri.host.empty?
raise ArgumentError, "maildir URI must have a path component" unless uri.path
@sync_back = sync_back
diff --git a/lib/sup/mbox.rb b/lib/sup/mbox.rb
@@ -30,7 +30,7 @@ class MBox < Source
end
raise ArgumentError, "not an mbox uri" unless uri.scheme == "mbox"
- raise ArgumentError, "mbox URI ('#{uri}') cannot have a host: #{uri.host}" if uri.host
+ raise ArgumentError, "mbox URI ('#{uri}') cannot have a host: #{uri.host}" unless uri.host.nil? || uri.host.empty?
raise ArgumentError, "mbox URI must have a path component" unless uri.path
@f = nil
else