From 1c13f588ba6b25af03dc90f43f2be518fea547c3 Mon Sep 17 00:00:00 2001 From: Eduardo Resende Date: Thu, 20 Feb 2025 19:27:32 -0300 Subject: [PATCH 1/3] Fix Qpid::Proton::DEFAULT_URI_PARSER for Ruby 3.4 --- ruby/lib/core/uri.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ruby/lib/core/uri.rb b/ruby/lib/core/uri.rb index d5d0dd67a7..3e08f0ada6 100644 --- a/ruby/lib/core/uri.rb +++ b/ruby/lib/core/uri.rb @@ -45,8 +45,16 @@ class AMQPS < AMQP module Qpid::Proton private - # Make sure to allow empty hostnames, Ruby 2.0.0 does not. - DEFAULT_URI_PARSER = URI::Parser.new(:HOSTNAME => /(?:#{URI::PATTERN::HOSTNAME})|/) + # Make sure to allow empty hostnames + class CustomURIParser < URI::RFC3986_Parser + def parse(uri) + uri = super(uri) + uri.host = '' if uri.host.nil? || uri.host.empty? + uri + end + end + + DEFAULT_URI_PARSER = CustomURIParser.new public From 72947b5fc95971facadb3d80efee237d072468be Mon Sep 17 00:00:00 2001 From: Eduardo Resende Date: Fri, 21 Feb 2025 11:08:18 -0300 Subject: [PATCH 2/3] refactoring parser --- ruby/lib/core/uri.rb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/ruby/lib/core/uri.rb b/ruby/lib/core/uri.rb index 3e08f0ada6..ef759b5982 100644 --- a/ruby/lib/core/uri.rb +++ b/ruby/lib/core/uri.rb @@ -45,16 +45,8 @@ class AMQPS < AMQP module Qpid::Proton private - # Make sure to allow empty hostnames - class CustomURIParser < URI::RFC3986_Parser - def parse(uri) - uri = super(uri) - uri.host = '' if uri.host.nil? || uri.host.empty? - uri - end - end - - DEFAULT_URI_PARSER = CustomURIParser.new + # Make sure to allow empty hostnames, Ruby 2.0.0 does not. + DEFAULT_URI_PARSER = URI::RFC2396_Parser.new(:HOSTNAME => /(?:#{URI::PATTERN::HOSTNAME})|/) public From 62f7a0a25adeeac7d10f53dc33c8c90cd955c538 Mon Sep 17 00:00:00 2001 From: Eduardo Resende Date: Wed, 26 Feb 2025 13:58:26 -0300 Subject: [PATCH 3/3] define DEFAULT_URI_PARSER according to Ruby version --- ruby/lib/core/uri.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ruby/lib/core/uri.rb b/ruby/lib/core/uri.rb index ef759b5982..c1f5671d75 100644 --- a/ruby/lib/core/uri.rb +++ b/ruby/lib/core/uri.rb @@ -46,7 +46,12 @@ class AMQPS < AMQP module Qpid::Proton private # Make sure to allow empty hostnames, Ruby 2.0.0 does not. - DEFAULT_URI_PARSER = URI::RFC2396_Parser.new(:HOSTNAME => /(?:#{URI::PATTERN::HOSTNAME})|/) + DEFAULT_URI_PARSER = + if RUBY_VERSION >= '3.4' + URI::RFC2396_Parser.new(:HOSTNAME => /(?:#{URI::PATTERN::HOSTNAME})|/) + else + URI::Parser.new(:HOSTNAME => /(?:#{URI::PATTERN::HOSTNAME})|/) + end public