secobarbital-cookiejar 0.2.9.2 → 0.2.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cookiejar.rb +3 -0
- data/lib/cookiejar/cookie.rb +2 -2
- data/lib/cookiejar/cookie_validation.rb +7 -5
- data/lib/cookiejar/jar.rb +2 -1
- data/test/cookie_validation_test.rb +6 -0
- metadata +20 -5
data/lib/cookiejar.rb
CHANGED
data/lib/cookiejar/cookie.rb
CHANGED
@@ -156,10 +156,10 @@ module CookieJar
|
|
156
156
|
# being sent over http, and it must not be a http_only cookie sent to
|
157
157
|
# a script
|
158
158
|
path_match = uri.path.start_with? @path
|
159
|
-
secure_match = !(@secure && uri.scheme == 'http')
|
159
|
+
secure_match = !(@secure && uri.scheme.downcase == 'http')
|
160
160
|
script_match = !(script && @http_only)
|
161
161
|
expiry_match = !expired?
|
162
|
-
ports_match = ports.nil? || (ports.include? uri.port)
|
162
|
+
ports_match = ports.nil? || (ports.include? uri.port || uri.inferred_port)
|
163
163
|
path_match && secure_match && script_match && expiry_match && ports_match
|
164
164
|
end
|
165
165
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'cgi'
|
2
|
+
require 'addressable/uri'
|
2
3
|
require 'uri'
|
4
|
+
|
3
5
|
module CookieJar
|
4
6
|
# Represents a set of cookie validation errors
|
5
7
|
class InvalidCookieError < StandardError
|
@@ -51,7 +53,7 @@ module CookieJar
|
|
51
53
|
# @param [String, URI] request_uri URI we are normalizing
|
52
54
|
# @param [URI] URI representation of input string, or original URI
|
53
55
|
def self.to_uri request_uri
|
54
|
-
|
56
|
+
Addressable::URI.parse request_uri
|
55
57
|
end
|
56
58
|
|
57
59
|
# Converts an input cookie or uri to a string representing the path.
|
@@ -60,7 +62,7 @@ module CookieJar
|
|
60
62
|
# @param [String, URI, Cookie] object containing the path
|
61
63
|
# @return [String] path information
|
62
64
|
def self.to_path uri_or_path
|
63
|
-
if (uri_or_path.is_a? URI) || (uri_or_path.is_a? Cookie)
|
65
|
+
if (uri_or_path.is_a? URI) || (uri_or_path.is_a? Addressable::URI) || (uri_or_path.is_a? Cookie)
|
64
66
|
uri_or_path.path
|
65
67
|
else
|
66
68
|
uri_or_path
|
@@ -73,7 +75,7 @@ module CookieJar
|
|
73
75
|
# @param [String, URI, Cookie] object containing the domain
|
74
76
|
# @return [String] domain information.
|
75
77
|
def self.to_domain uri_or_domain
|
76
|
-
if uri_or_domain.is_a? URI
|
78
|
+
if (uri_or_domain.is_a? URI) || (uri_or_domain.is_a? Addressable::URI)
|
77
79
|
uri_or_domain.host
|
78
80
|
elsif uri_or_domain.is_a? Cookie
|
79
81
|
uri_or_domain.domain
|
@@ -231,7 +233,7 @@ module CookieJar
|
|
231
233
|
uri = to_uri request_uri
|
232
234
|
request_host = effective_host uri.host
|
233
235
|
request_path = uri.path
|
234
|
-
request_secure = (uri.scheme == 'https')
|
236
|
+
request_secure = (uri.scheme.downcase == 'https')
|
235
237
|
cookie_host = cookie.domain
|
236
238
|
cookie_path = cookie.path
|
237
239
|
|
@@ -270,7 +272,7 @@ module CookieJar
|
|
270
272
|
# The Port attribute has a "port-list", and the request-port was
|
271
273
|
# not in the list.
|
272
274
|
unless cookie.ports.nil? || cookie.ports.length != 0
|
273
|
-
unless cookie.ports.find_index uri.port
|
275
|
+
unless cookie.ports.find_index uri.port || uri.inferred_port
|
274
276
|
errors << "Ports list does not contain request URI port"
|
275
277
|
end
|
276
278
|
end
|
data/lib/cookiejar/jar.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'cookiejar/cookie'
|
2
|
+
require 'addressable/uri'
|
2
3
|
|
3
4
|
module CookieJar
|
4
5
|
# A cookie store for client side usage.
|
@@ -289,7 +290,7 @@ module CookieJar
|
|
289
290
|
end
|
290
291
|
|
291
292
|
def to_uri request_uri
|
292
|
-
|
293
|
+
Addressable::URI.parse request_uri
|
293
294
|
end
|
294
295
|
|
295
296
|
def find_domain host
|
@@ -96,6 +96,9 @@ describe CookieValidation do
|
|
96
96
|
it "should handle URI objects" do
|
97
97
|
CookieValidation.cookie_base_path(URI.parse('http://www.foo.com/bar/')).should == '/bar/'
|
98
98
|
end
|
99
|
+
it "should handle Addressable URI objects" do
|
100
|
+
CookieValidation.cookie_base_path(Addressable::URI.parse('http://www.foo.com/bar/')).should == '/bar/'
|
101
|
+
end
|
99
102
|
it "should preserve case" do
|
100
103
|
CookieValidation.cookie_base_path("/BaR/").should == '/BaR/'
|
101
104
|
end
|
@@ -108,6 +111,9 @@ describe CookieValidation do
|
|
108
111
|
it "should handle URI objects" do
|
109
112
|
CookieValidation.determine_cookie_path(URI.parse('http://foo.com/bar/'), '').should == '/bar/'
|
110
113
|
end
|
114
|
+
it "should handle Addressable URI objects" do
|
115
|
+
CookieValidation.determine_cookie_path(Addressable::URI.parse('http://foo.com/bar/'), '').should == '/bar/'
|
116
|
+
end
|
111
117
|
it "should handle Cookie objects" do
|
112
118
|
cookie = Cookie.from_set_cookie('http://foo.com/', "name=value;path=/")
|
113
119
|
CookieValidation.determine_cookie_path('http://foo.com/', cookie).should == '/'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secobarbital-cookiejar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 125
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
9
|
- 9
|
10
|
-
-
|
11
|
-
version: 0.2.9.
|
10
|
+
- 3
|
11
|
+
version: 0.2.9.3
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- David Waite
|
@@ -19,8 +19,23 @@ cert_chain: []
|
|
19
19
|
|
20
20
|
date: 2010-06-04 00:00:00 -07:00
|
21
21
|
default_executable:
|
22
|
-
dependencies:
|
23
|
-
|
22
|
+
dependencies:
|
23
|
+
- !ruby/object:Gem::Dependency
|
24
|
+
name: addressable
|
25
|
+
prerelease: false
|
26
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
|
+
requirements:
|
29
|
+
- - ~>
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
hash: 3
|
32
|
+
segments:
|
33
|
+
- 2
|
34
|
+
- 2
|
35
|
+
- 2
|
36
|
+
version: 2.2.2
|
37
|
+
type: :runtime
|
38
|
+
version_requirements: *id001
|
24
39
|
description: Allows for parsing and returning cookies in Ruby HTTP client code
|
25
40
|
email:
|
26
41
|
- david@alkaline-solutions.com
|