Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
fcf0b378
Commit
fcf0b378
authored
Aug 22, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[OpenURI] Support for unsafe redirects.
parent
dc04fc22
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
2 deletions
+42
-2
dependency.rb
lib/cocoapods/dependency.rb
+2
-2
open_uri.rb
lib/cocoapods/open_uri.rb
+40
-0
No files found.
lib/cocoapods/dependency.rb
View file @
fcf0b378
require
'
open-
uri'
require
'
cocoapods/open_
uri'
module
Pod
class
Dependency
<
Gem
::
Dependency
...
...
@@ -192,7 +192,7 @@ module Pod
output_path
=
sandbox
.
root
+
"Local Podspecs/
#{
name
}
.podspec"
output_path
.
dirname
.
mkpath
puts
" * Fetching podspec for `
#{
name
}
' from:
#{
@params
[
:podspec
]
}
"
unless
config
.
silent?
open
(
@params
[
:podspec
])
do
|
io
|
open
(
@params
[
:podspec
]
,
{
:allow_unsafe_redirects
=>
true
}
)
do
|
io
|
output_path
.
open
(
'w'
)
{
|
f
|
f
<<
io
.
read
}
end
end
...
...
lib/cocoapods/open_uri.rb
0 → 100644
View file @
fcf0b378
require
'open-uri'
#
# From: https://gist.github.com/1271420
#
# Allow open-uri to follow unsafe redirects (i.e. https to http).
# Relevant issue:
# http://redmine.ruby-lang.org/issues/3719
# Source here:
# https://github.com/ruby/ruby/blob/trunk/lib/open-uri.rb
module
OpenURI
class
<<
self
alias_method
:open_uri_original
,
:open_uri
alias_method
:redirectable_cautious?
,
:redirectable?
def
redirectable_baller?
uri1
,
uri2
valid
=
/\A(?:https?|ftp)\z/i
valid
=~
uri1
.
scheme
.
downcase
&&
valid
=~
uri2
.
scheme
end
end
# The original open_uri takes *args but then doesn't do anything with them.
# Assume we can only handle a hash.
def
self
.
open_uri
name
,
options
=
{},
&
block
value
=
options
.
delete
:allow_unsafe_redirects
if
value
class
<<
self
remove_method
:redirectable?
alias_method
:redirectable?
,
:redirectable_baller?
end
else
class
<<
self
remove_method
:redirectable?
alias_method
:redirectable?
,
:redirectable_cautious?
end
end
self
.
open_uri_original
name
,
options
,
&
block
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment