macmillan-utils 1.0.37 → 1.0.38

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 182d2d0bb630acae2ae30f20790d50cae2faca04
4
- data.tar.gz: 160bd16626cf37def232a5854825fb83e226ab97
3
+ metadata.gz: efd65c066b1290468c8b0a29bc2e4c1bf3a579de
4
+ data.tar.gz: 0dec24f8ee60517ab43acca34fa5f2b00bafb671
5
5
  SHA512:
6
- metadata.gz: e8d300ec617b865faa81b673dd5919b06c2519ef17736a0b9d2dedaeca8071e35037525bf608e87ec49a30f042cb8a4f6dd4ba2d24599d04490a93920683ccbf
7
- data.tar.gz: decfab1462fad72ac385f0e35083030f5414d471244a2908702cf132b8fc47cf03128f399609cf4d5486432d4f13ac84a426db4f0b67f1b4871bd6ef8bcd7134
6
+ metadata.gz: d9dff2f8d7e9344c98d22688be63a2c646e3e05312c9cd6a563f488f1fc4b09284aabf11c668807e696c9e0182b2ed67503d614885309dff3f019ee8c0c41ef3
7
+ data.tar.gz: b74774439c576d01acca98f031a8a8dc1255f734cf3aeb687fcf26716291584d61b286b36ac4d32a8adc61b34c9a6c76cd1f6b787445d6dd608b6e5df5e33f62
@@ -28,19 +28,19 @@ module Macmillan
28
28
  def cookies_accepted?(request)
29
29
 
30
30
  debug_log("request.post? IS #{request.post?.inspect}")
31
- debug_log("request.cookies[#{COOKIE}] IS #{request.cookies[COOKIE]}")
32
- debug_log("request.params['cookies'] IS #{request.params['cookies']}")
31
+ debug_log("request.cookies[#{COOKIE}] IS #{request.cookies[COOKIE].inspect}")
32
+ debug_log("request.params['cookies'] IS #{request.params['cookies'].inspect}")
33
33
 
34
34
  unless request.post?
35
- debug_log("request.post? (#{request.post?.inspect}) means pass-thru")
35
+ debug_log("request.post? (#{request.post?.inspect}) means passthru")
36
36
  return false
37
37
  end
38
38
  unless request.cookies[COOKIE] != 'accepted'
39
- debug_log("request.cookies[#{COOKIE}] (#{request.cookies[COOKIE]}) means passthru")
39
+ debug_log("request.cookies['#{COOKIE}'] (#{request.cookies[COOKIE].inspect}) means passthru")
40
40
  return false
41
41
  end
42
42
  unless request.params['cookies'] == 'accepted'
43
- debug_log("request.params['cookies'] (#{request.params['cookies']}) means passthru")
43
+ debug_log("request.params['cookies'] (#{request.params['cookies'].inspect}) means passthru")
44
44
  return false
45
45
  end
46
46
  debug_log('About to set the acceptance cookie and redirect')
@@ -48,7 +48,7 @@ module Macmillan
48
48
  end
49
49
 
50
50
  def debug_log(msg)
51
- logger.info("[Macmillan::Utils::Middleware::CookieMessage] #{msg}")
51
+ logger.info("[Macmillan::Utils::Middleware::CookieMessage] #{msg}\n")
52
52
  end
53
53
 
54
54
  def logger
@@ -78,17 +78,23 @@ module Macmillan
78
78
 
79
79
  def build_location(request)
80
80
  begin
81
+ debug_log("Attempting to determine redirect by parsing referrer #{request.referrer}")
81
82
  uri = URI.parse(request.referrer.to_s)
82
83
  rescue URI::InvalidURIError
84
+ debug_log("No that failed, attempting to determine redirect by parsing request.url #{request.url}")
83
85
  uri = URI.parse(request.url)
84
86
  end
85
87
 
86
88
  # Check that the redirect is an internal one for security reasons:
87
89
  # https://webmasters.googleblog.com/2009/01/open-redirect-urls-is-your-site-being.html
90
+ unless internal_redirect?(request, uri)
91
+ debug_log("Not internal redirect - so changing to #{request.url} instead of the above")
92
+ end
88
93
  internal_redirect?(request, uri) ? uri.to_s : request.url
89
94
  end
90
95
 
91
96
  def internal_redirect?(request, uri)
97
+ debug_log("Is redirect to #{uri.host}:#{uri.port} internal WRT #{request.host}:#{request.port}")
92
98
  request.host == uri.host && request.port == uri.port
93
99
  end
94
100
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: macmillan-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.37
4
+ version: 1.0.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Springer Nature
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-17 00:00:00.000000000 Z
11
+ date: 2017-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler