From bae03f2ee2586eb25d000c8d3615d4b833382236 Mon Sep 17 00:00:00 2001 From: Dimitris Koutsogiorgas Date: Sat, 11 Sep 2021 16:21:39 -0700 Subject: [PATCH] Handle spec repo urls with user info when determining if they are CDN. --- CHANGELOG.md | 4 ++++ lib/cocoapods/sources_manager.rb | 7 +++++-- spec/unit/sources_manager_spec.rb | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cdac21c28..ed3c05abf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ##### Bug Fixes +* Handle spec repo urls with user info when determining if they are CDN. + [Dimitris Koutsogiorgas](https://github.com/dnkoutso) + [#10941](https://github.com/CocoaPods/CocoaPods/issues/10941) + * Set `INFOPLIST_FILE` build setting to `$(SRCROOT)/App/App-Info.plist` during lint. [Dimitris Koutsogiorgas](https://github.com/dnkoutso) [#10927](https://github.com/CocoaPods/CocoaPods/issues/10927) diff --git a/lib/cocoapods/sources_manager.rb b/lib/cocoapods/sources_manager.rb index 174afde3d2..540915db4c 100644 --- a/lib/cocoapods/sources_manager.rb +++ b/lib/cocoapods/sources_manager.rb @@ -71,12 +71,15 @@ def create_source_with_url(url) # The URL of the source. # def cdn_url?(url) - return unless url =~ %r{^https?:\/\/} + return false unless url =~ %r{^https?:\/\/} uri_options = {} netrc_info = Netrc.read - netrc_host = URI.parse(url).host + uri = URI.parse(url) + return false unless uri.userinfo.nil? + + netrc_host = uri.host credentials = netrc_info[netrc_host] uri_options[:http_basic_authentication] = credentials if credentials diff --git a/spec/unit/sources_manager_spec.rb b/spec/unit/sources_manager_spec.rb index 94e5db1ff4..de07e65a7d 100644 --- a/spec/unit/sources_manager_spec.rb +++ b/spec/unit/sources_manager_spec.rb @@ -154,6 +154,10 @@ module Pod @sources_manager.cdn_url?('http://cdn.cocoapods.org').should == true end + it 'spec repo with userinfo' do + @sources_manager.cdn_url?('https://foo:bar@bitbucket.org/foobar/Specs.git').should == false + end + it 'git master spec repo' do stub_as_404('https://github.com/cocoapods/specs.git') stub_as_404('https://github.com/cocoapods/specs')