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
7691aedd
Commit
7691aedd
authored
Apr 07, 2014
by
Boris Bügling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not follow redirects infinitely.
parent
1bc839c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
validator.rb
lib/cocoapods/validator.rb
+6
-0
validator_spec.rb
spec/unit/validator_spec.rb
+8
-0
No files found.
lib/cocoapods/validator.rb
View file @
7691aedd
...
...
@@ -222,6 +222,8 @@ module Pod
attr_accessor
:consumer
attr_accessor
:subspec_name
MAX_HTTP_REDIRECTS
=
3
# Performs validations related to the `homepage` attribute.
#
def
validate_homepage
(
spec
)
...
...
@@ -230,6 +232,7 @@ module Pod
return
unless
homepage
begin
redirects
=
0
resp
=
nil
loop
do
resp
=
::
REST
.
head
(
homepage
)
...
...
@@ -240,9 +243,12 @@ module Pod
if
[
301
,
302
,
303
,
307
,
308
].
include?
resp
.
status_code
homepage
=
resp
.
headers
[
'location'
].
first
redirects
+=
1
else
break
end
break
unless
redirects
<
MAX_HTTP_REDIRECTS
end
rescue
warning
"There was a problem validating the homepage."
...
...
spec/unit/validator_spec.rb
View file @
7691aedd
...
...
@@ -125,6 +125,14 @@ module Pod
@sut
.
validate
@sut
.
results
.
length
.
should
.
equal
0
end
it
"does not follow redirects infinitely"
do
WebMock
::
API
.
stub_request
(
:head
,
/redirect/
).
to_return
(
:status
=>
301
,
:headers
=>
{
'Location'
=>
'http://banana-corp.local/redirect/'
}
)
Specification
.
any_instance
.
stubs
(
:homepage
).
returns
(
'http://banana-corp.local/redirect/'
)
@sut
.
validate
@sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/The homepage is not reachable/
end
end
it
"respects the no clean option"
do
...
...
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