From 4a24bb850749421c364c85e1f7c47c5d7fce7415 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Tue, 15 Aug 2017 15:30:45 +0200 Subject: [PATCH] Applied currently available fix for ruby 'open-uri' bug described in pull request #1675. Using 'open' with a temp file causes an exception. This is caused by the newly introduced Exchange integration dependencies 'viewpoint' and 'autodiscover' which depend on 'httpclient' which requires 'open-uri' somewhere. These cause the integration tests to fail - namely UserAgentTest#test_check_request. Link: https://github.com/ruby/ruby/pull/1675 --- lib/core_ext/open-uri.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lib/core_ext/open-uri.rb diff --git a/lib/core_ext/open-uri.rb b/lib/core_ext/open-uri.rb new file mode 100644 index 000000000..703b20594 --- /dev/null +++ b/lib/core_ext/open-uri.rb @@ -0,0 +1,20 @@ +# rubocop:disable Style/FileName +if Kernel.respond_to?(:open_uri_original_open) + module Kernel + private + + # see: https://github.com/ruby/ruby/pull/1675 + def open(name, *rest, &block) # :doc: + if name.respond_to?(:open) && !name.method(:open).parameters.empty? + name.open(*rest, &block) + elsif name.respond_to?(:to_str) && + %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ name && + (uri = URI.parse(name)).respond_to?(:open) + uri.open(*rest, &block) + else + open_uri_original_open(name, *rest, &block) + end + end + module_function :open + end +end