http-cookie 1.0.5 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +51 -0
- data/LICENSE.txt +1 -1
- data/README.md +5 -2
- data/lib/http/cookie/scanner.rb +4 -3
- data/lib/http/cookie/uri_parser.rb +36 -0
- data/lib/http/cookie/version.rb +1 -1
- data/lib/http/cookie.rb +18 -11
- data/lib/http/cookie_jar/abstract_saver.rb +11 -22
- data/lib/http/cookie_jar/abstract_store.rb +14 -19
- data/lib/http/cookie_jar/cookiestxt_saver.rb +0 -1
- data/lib/http/cookie_jar/hash_store.rb +0 -1
- data/lib/http/cookie_jar/mozilla_store.rb +19 -15
- data/lib/http/cookie_jar/yaml_saver.rb +5 -11
- data/lib/http/cookie_jar.rb +6 -22
- metadata +8 -25
- data/.github/workflows/ci.yml +0 -37
- data/.gitignore +0 -17
- data/Gemfile +0 -4
- data/Rakefile +0 -20
- data/http-cookie.gemspec +0 -35
- data/test/helper.rb +0 -55
- data/test/mechanize.yml +0 -101
- data/test/simplecov_start.rb +0 -2
- data/test/test_http_cookie.rb +0 -1134
- data/test/test_http_cookie_jar.rb +0 -988
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cee8102244e13cc21f70ae293cd86a7041b4f9d80f1938af1b75e43c132529ef
|
|
4
|
+
data.tar.gz: '018cea8d124fc781651229000a955f43d78cfb5022d843d5f4a09dd6c9bae2d0'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e74a4eab20889a2f52cc19348ac9e4cfeb62e31b9987ef4c469835654184d000ebfe9550308162ddd97d389420597471bf57a6b9d313f93b521f9ffb86fcae26
|
|
7
|
+
data.tar.gz: c0fa2fe8224c168ffedb940baa6f83b8f7f15585d80bd84ef64b1f4a5f14d311b86ea72b1b1e2c93d9d444ad8499a4cb2def2de7c10cba77f54cbd4701591a91
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
+
## 1.1.5 (2026-04-19)
|
|
2
|
+
|
|
3
|
+
- Fix `NameError: uninitialized constant HTTP::Cookie::MAX_COOKIES_TOTAL` when `http/cookie_jar` is required without `http/cookie`, as done by the `http` gem. (#62)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## 1.1.4 (2026-04-07)
|
|
7
|
+
|
|
8
|
+
- Fix `require "http/cookie_jar"` raising `NameError: uninitialized constant HTTP`. (#61)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## 1.1.3 (2026-04-06)
|
|
12
|
+
|
|
13
|
+
- Restore compatibility with Ruby 2.6.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## 1.1.2 (2026-04-06)
|
|
17
|
+
|
|
18
|
+
- Stop requiring sqlite3 at load time by changing `MozillaStore::Database` from inheritance to composition.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## 1.1.1 (2026-04-06)
|
|
22
|
+
|
|
23
|
+
- Fix thread-unsafe runtime requires. (#43 by @brasic, #57)
|
|
24
|
+
- Replace `require 'cgi'` with `require 'cgi/escape'` to suppress Ruby 4.0 warning. (#56 by @dominion525)
|
|
25
|
+
- Do not define `MozillaStore` on JRuby; leave the constant undefined instead.
|
|
26
|
+
- Relax sqlite3 development dependency to `>= 1.3`.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## 1.1.0 (2025-09-26)
|
|
30
|
+
|
|
31
|
+
- Implement `Cookie#to_h`. (#55) @luke-hill @flavorjones
|
|
32
|
+
- Reduce gem size by excluding test files (#54) @yuri-zubov
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## 1.0.8 (2024-12-05)
|
|
36
|
+
|
|
37
|
+
- `Cookie#expires=` accepts `DateTime` objects. (#52) @luke-hill @flavorjones
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## 1.0.7 (2024-06-06)
|
|
41
|
+
|
|
42
|
+
- Explicitly require "cgi" to avoid `NameError` in some applications. (#50 by @flavorjones)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## 1.0.6 (2024-06-01)
|
|
46
|
+
|
|
47
|
+
- Fix error formatting bug in HTTP::CookieJar::AbstractStore (#42 by @andrelaszlo)
|
|
48
|
+
- Allow non-RFC 3986-compliant URLs (#45 by @c960657)
|
|
49
|
+
- Add coverage for Ruby 3.2 and 3.3 (#46 by @flavorjones)
|
|
50
|
+
- Quash ruby 3.4 warnings (#47 by @flavorjones)
|
|
51
|
+
|
|
1
52
|
## 1.0.5 (2022-05-25)
|
|
2
53
|
|
|
3
54
|
- Silence SQLite3 warnings
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[](https://badge.fury.io/rb/http-cookie)
|
|
2
|
+
|
|
1
3
|
# HTTP::Cookie
|
|
2
4
|
|
|
3
5
|
HTTP::Cookie is a ruby library to handle HTTP cookies in a way both
|
|
@@ -20,7 +22,8 @@ The following is an incomplete list of its features:
|
|
|
20
22
|
* It takes eTLD (effective TLD, also known as "Public Suffix") into
|
|
21
23
|
account just as major browsers do, to reject cookies with an eTLD
|
|
22
24
|
domain like "org", "co.jp", or "appspot.com". This feature is
|
|
23
|
-
brought to you by the
|
|
25
|
+
brought to you by the
|
|
26
|
+
[domain_name](https://github.com/knu/ruby-domain_name) gem.
|
|
24
27
|
|
|
25
28
|
* The number of cookies and the size are properly capped so that a
|
|
26
29
|
cookie store does not get flooded.
|
|
@@ -207,7 +210,7 @@ equivalent using HTTP::Cookie:
|
|
|
207
210
|
guarantee that it will remain available in the future.
|
|
208
211
|
|
|
209
212
|
|
|
210
|
-
HTTP::Cookie/CookieJar
|
|
213
|
+
HTTP::Cookie/CookieJar raises runtime errors to help migration, so
|
|
211
214
|
after replacing the class names, try running your test code once to
|
|
212
215
|
find out how to fix your code base.
|
|
213
216
|
|
data/lib/http/cookie/scanner.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'http/cookie'
|
|
2
3
|
require 'strscan'
|
|
3
4
|
require 'time'
|
|
@@ -23,7 +24,7 @@ class HTTP::Cookie::Scanner < StringScanner
|
|
|
23
24
|
class << self
|
|
24
25
|
def quote(s)
|
|
25
26
|
return s unless s.match(RE_BAD_CHAR)
|
|
26
|
-
'"' << s.gsub(/([\\"])/, "\\\\\\1") << '"'
|
|
27
|
+
(+'"') << s.gsub(/([\\"])/, "\\\\\\1") << '"'
|
|
27
28
|
end
|
|
28
29
|
end
|
|
29
30
|
|
|
@@ -32,7 +33,7 @@ class HTTP::Cookie::Scanner < StringScanner
|
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
def scan_dquoted
|
|
35
|
-
''.tap { |s|
|
|
36
|
+
(+'').tap { |s|
|
|
36
37
|
case
|
|
37
38
|
when skip(/"/)
|
|
38
39
|
break
|
|
@@ -51,7 +52,7 @@ class HTTP::Cookie::Scanner < StringScanner
|
|
|
51
52
|
end
|
|
52
53
|
|
|
53
54
|
def scan_value(comma_as_separator = false)
|
|
54
|
-
''.tap { |s|
|
|
55
|
+
(+'').tap { |s|
|
|
55
56
|
case
|
|
56
57
|
when scan(/[^,;"]+/)
|
|
57
58
|
s << matched
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module HTTP::Cookie::URIParser
|
|
2
|
+
module_function
|
|
3
|
+
|
|
4
|
+
# Regular Expression taken from RFC 3986 Appendix B
|
|
5
|
+
URIREGEX = %r{
|
|
6
|
+
\A
|
|
7
|
+
(?: (?<scheme> [^:/?\#]+ ) : )?
|
|
8
|
+
(?: // (?<authority> [^/?\#]* ) )?
|
|
9
|
+
(?<path> [^?\#]* )
|
|
10
|
+
(?: \? (?<query> [^\#]* ) )?
|
|
11
|
+
(?: \# (?<fragment> .* ) )?
|
|
12
|
+
\z
|
|
13
|
+
}x
|
|
14
|
+
|
|
15
|
+
# Escape RFC 3986 "reserved" characters minus valid characters for path
|
|
16
|
+
# More specifically, gen-delims minus "/" / "?" / "#"
|
|
17
|
+
def escape_path(path)
|
|
18
|
+
path.sub(/\A[^?#]+/) { |p| p.gsub(/[:\[\]@]+/) { |r| CGI.escape(r) } }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Parse a URI string or object, relaxing the constraints on the path component
|
|
22
|
+
def parse(uri)
|
|
23
|
+
URI(uri)
|
|
24
|
+
rescue URI::InvalidURIError
|
|
25
|
+
str = String.try_convert(uri) or
|
|
26
|
+
raise ArgumentError, "bad argument (expected URI object or URI string)"
|
|
27
|
+
|
|
28
|
+
m = URIREGEX.match(str) or raise
|
|
29
|
+
|
|
30
|
+
path = m[:path]
|
|
31
|
+
str[m.begin(:path)...m.end(:path)] = escape_path(path)
|
|
32
|
+
uri = URI.parse(str)
|
|
33
|
+
uri.__send__(:set_path, path)
|
|
34
|
+
uri
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/http/cookie/version.rb
CHANGED
data/lib/http/cookie.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# :markup: markdown
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
require 'http/cookie/version'
|
|
4
|
+
require 'http/cookie/uri_parser'
|
|
3
5
|
require 'time'
|
|
4
6
|
require 'uri'
|
|
5
7
|
require 'domain_name'
|
|
6
8
|
require 'http/cookie/ruby_compat'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
autoload :CookieJar, 'http/cookie_jar'
|
|
10
|
-
end
|
|
9
|
+
require 'cgi/escape'
|
|
10
|
+
require 'http/cookie_jar'
|
|
11
11
|
|
|
12
12
|
# This class is used to represent an HTTP Cookie.
|
|
13
13
|
class HTTP::Cookie
|
|
@@ -86,7 +86,7 @@ class HTTP::Cookie
|
|
|
86
86
|
|
|
87
87
|
# The Expires attribute value as a Time object.
|
|
88
88
|
#
|
|
89
|
-
# The setter method accepts a Time object, a string representation
|
|
89
|
+
# The setter method accepts a Time / DateTime object, a string representation
|
|
90
90
|
# of date/time that Time.parse can understand, or `nil`.
|
|
91
91
|
#
|
|
92
92
|
# Setting this value resets #max_age to nil. When #max_age is
|
|
@@ -275,7 +275,7 @@ class HTTP::Cookie
|
|
|
275
275
|
logger = options[:logger]
|
|
276
276
|
created_at = options[:created_at]
|
|
277
277
|
end
|
|
278
|
-
origin =
|
|
278
|
+
origin = HTTP::Cookie::URIParser.parse(origin)
|
|
279
279
|
|
|
280
280
|
[].tap { |cookies|
|
|
281
281
|
Scanner.new(set_cookie, logger).scan_set_cookie { |name, value, attrs|
|
|
@@ -424,7 +424,7 @@ class HTTP::Cookie
|
|
|
424
424
|
# Returns the domain, with a dot prefixed only if the domain flag is
|
|
425
425
|
# on.
|
|
426
426
|
def dot_domain
|
|
427
|
-
@for_domain ? '.' << @domain : @domain
|
|
427
|
+
@for_domain ? (+'.') << @domain : @domain
|
|
428
428
|
end
|
|
429
429
|
|
|
430
430
|
# Returns the domain attribute value as a DomainName object.
|
|
@@ -455,7 +455,7 @@ class HTTP::Cookie
|
|
|
455
455
|
@origin.nil? or
|
|
456
456
|
raise ArgumentError, "origin cannot be changed once it is set"
|
|
457
457
|
# Delay setting @origin because #domain= or #path= may fail
|
|
458
|
-
origin =
|
|
458
|
+
origin = HTTP::Cookie::URIParser.parse(origin)
|
|
459
459
|
if URI::HTTP === origin
|
|
460
460
|
self.domain ||= origin.host
|
|
461
461
|
self.path ||= (origin + './').path
|
|
@@ -490,6 +490,8 @@ class HTTP::Cookie
|
|
|
490
490
|
def expires= t
|
|
491
491
|
case t
|
|
492
492
|
when nil, Time
|
|
493
|
+
when DateTime
|
|
494
|
+
t = t.to_time
|
|
493
495
|
else
|
|
494
496
|
t = Time.parse(t)
|
|
495
497
|
end
|
|
@@ -548,7 +550,7 @@ class HTTP::Cookie
|
|
|
548
550
|
# Tests if it is OK to accept this cookie if it is sent from a given
|
|
549
551
|
# URI/URL, `uri`.
|
|
550
552
|
def acceptable_from_uri?(uri)
|
|
551
|
-
uri =
|
|
553
|
+
uri = HTTP::Cookie::URIParser.parse(uri)
|
|
552
554
|
return false unless URI::HTTP === uri && uri.host
|
|
553
555
|
host = DomainName.new(uri.host)
|
|
554
556
|
|
|
@@ -585,7 +587,7 @@ class HTTP::Cookie
|
|
|
585
587
|
if @domain.nil?
|
|
586
588
|
raise "cannot tell if this cookie is valid because the domain is unknown"
|
|
587
589
|
end
|
|
588
|
-
uri =
|
|
590
|
+
uri = HTTP::Cookie::URIParser.parse(uri)
|
|
589
591
|
# RFC 6265 5.4
|
|
590
592
|
return false if secure? && !(URI::HTTPS === uri)
|
|
591
593
|
acceptable_from_uri?(uri) && HTTP::Cookie.path_match?(@path, uri.path)
|
|
@@ -594,7 +596,7 @@ class HTTP::Cookie
|
|
|
594
596
|
# Returns a string for use in the Cookie header, i.e. `name=value`
|
|
595
597
|
# or `name="value"`.
|
|
596
598
|
def cookie_value
|
|
597
|
-
"#{@name}=#{Scanner.quote(@value)}"
|
|
599
|
+
+"#{@name}=#{Scanner.quote(@value)}"
|
|
598
600
|
end
|
|
599
601
|
alias to_s cookie_value
|
|
600
602
|
|
|
@@ -650,6 +652,11 @@ class HTTP::Cookie
|
|
|
650
652
|
end
|
|
651
653
|
include Comparable
|
|
652
654
|
|
|
655
|
+
# Hash serialization helper for use back into other libraries (Like Selenium)
|
|
656
|
+
def to_h
|
|
657
|
+
PERSISTENT_PROPERTIES.each_with_object({}) { |property, hash| hash[property.to_sym] = instance_variable_get("@#{property}") }
|
|
658
|
+
end
|
|
659
|
+
|
|
653
660
|
# YAML serialization helper for Syck.
|
|
654
661
|
def to_yaml_properties
|
|
655
662
|
PERSISTENT_PROPERTIES.map { |name| "@#{name}" }
|
|
@@ -2,29 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
# An abstract superclass for all saver classes.
|
|
4
4
|
class HTTP::CookieJar::AbstractSaver
|
|
5
|
-
class << self
|
|
6
|
-
@@class_map = {}
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@@class_map.fetch(symbol)
|
|
17
|
-
rescue LoadError, IndexError
|
|
18
|
-
raise IndexError, 'cookie saver unavailable: %s' % symbol.inspect
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def inherited(subclass) # :nodoc:
|
|
23
|
-
@@class_map[class_to_symbol(subclass)] = subclass
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def class_to_symbol(klass) # :nodoc:
|
|
27
|
-
klass.name[/[^:]+?(?=Saver$|$)/].downcase.to_sym
|
|
6
|
+
def self.implementation(symbol)
|
|
7
|
+
case symbol
|
|
8
|
+
when :yaml
|
|
9
|
+
HTTP::CookieJar::YAMLSaver
|
|
10
|
+
when :cookiestxt
|
|
11
|
+
HTTP::CookieJar::CookiestxtSaver
|
|
12
|
+
else
|
|
13
|
+
raise IndexError, 'cookie saver unavailable: %s' % symbol.inspect
|
|
28
14
|
end
|
|
29
15
|
end
|
|
30
16
|
|
|
@@ -63,3 +49,6 @@ class HTTP::CookieJar::AbstractSaver
|
|
|
63
49
|
# self
|
|
64
50
|
end
|
|
65
51
|
end
|
|
52
|
+
|
|
53
|
+
require "http/cookie_jar/yaml_saver"
|
|
54
|
+
require "http/cookie_jar/cookiestxt_saver"
|
|
@@ -6,29 +6,18 @@ class HTTP::CookieJar::AbstractStore
|
|
|
6
6
|
include MonitorMixin
|
|
7
7
|
|
|
8
8
|
class << self
|
|
9
|
-
@@class_map = {}
|
|
10
9
|
|
|
11
|
-
# Gets an implementation class by the name
|
|
12
|
-
# load "http/cookie_jar/*_store" if not found. If loading fails,
|
|
13
|
-
# IndexError is raised.
|
|
10
|
+
# Gets an implementation class by the name.
|
|
14
11
|
def implementation(symbol)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
raise IndexError, 'cookie store unavailable: %s
|
|
12
|
+
case symbol
|
|
13
|
+
when :hash
|
|
14
|
+
HTTP::CookieJar::HashStore
|
|
15
|
+
when :mozilla
|
|
16
|
+
HTTP::CookieJar::MozillaStore
|
|
17
|
+
else
|
|
18
|
+
raise IndexError, 'cookie store unavailable: %s' % symbol.inspect
|
|
22
19
|
end
|
|
23
20
|
end
|
|
24
|
-
|
|
25
|
-
def inherited(subclass) # :nodoc:
|
|
26
|
-
@@class_map[class_to_symbol(subclass)] = subclass
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def class_to_symbol(klass) # :nodoc:
|
|
30
|
-
klass.name[/[^:]+?(?=Store$|$)/].downcase.to_sym
|
|
31
|
-
end
|
|
32
21
|
end
|
|
33
22
|
|
|
34
23
|
# Defines options and their default values.
|
|
@@ -122,3 +111,9 @@ class HTTP::CookieJar::AbstractStore
|
|
|
122
111
|
# self
|
|
123
112
|
end
|
|
124
113
|
end
|
|
114
|
+
|
|
115
|
+
require 'http/cookie_jar/hash_store'
|
|
116
|
+
|
|
117
|
+
unless defined?(JRUBY_VERSION)
|
|
118
|
+
require 'http/cookie_jar/mozilla_store'
|
|
119
|
+
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# :markup: markdown
|
|
2
|
-
|
|
3
|
-
require 'sqlite3'
|
|
2
|
+
autoload :SQLite3, 'sqlite3'
|
|
4
3
|
|
|
5
4
|
class HTTP::CookieJar
|
|
6
5
|
# A store class that uses Mozilla compatible SQLite3 database as
|
|
@@ -38,20 +37,15 @@ class HTTP::CookieJar
|
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
class Database
|
|
42
|
-
def initialize(file
|
|
40
|
+
class Database
|
|
41
|
+
def initialize(file)
|
|
42
|
+
@db = SQLite3::Database.new(file, results_as_hash: true)
|
|
43
43
|
@stmts = []
|
|
44
|
-
options = {
|
|
45
|
-
:results_as_hash => true,
|
|
46
|
-
}.update(options)
|
|
47
|
-
super
|
|
48
44
|
end
|
|
49
45
|
|
|
50
46
|
def prepare(sql)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
@stmts << st
|
|
54
|
-
end
|
|
47
|
+
st = @db.prepare(sql)
|
|
48
|
+
@stmts << st if st.is_a?(SQLite3::Statement)
|
|
55
49
|
st
|
|
56
50
|
end
|
|
57
51
|
|
|
@@ -60,7 +54,19 @@ class HTTP::CookieJar
|
|
|
60
54
|
@stmts.reject! { |st|
|
|
61
55
|
st.closed? || st.close
|
|
62
56
|
}
|
|
63
|
-
|
|
57
|
+
@db.close
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def closed?
|
|
61
|
+
@db.closed?
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def execute(*args, &block)
|
|
65
|
+
@db.execute(*args, &block)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def create_function(*args, &block)
|
|
69
|
+
@db.create_function(*args, &block)
|
|
64
70
|
end
|
|
65
71
|
end
|
|
66
72
|
# :startdoc:
|
|
@@ -400,8 +406,6 @@ class HTTP::CookieJar
|
|
|
400
406
|
}
|
|
401
407
|
end
|
|
402
408
|
else
|
|
403
|
-
require 'cgi'
|
|
404
|
-
|
|
405
409
|
def encode_www_form(enum)
|
|
406
410
|
enum.map { |k, v| "#{CGI.escape(k)}=#{CGI.escape(v)}" }.join('&')
|
|
407
411
|
end
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# :markup: markdown
|
|
2
|
-
|
|
3
|
-
require 'psych' if !defined?(YAML) && RUBY_VERSION == "1.9.2"
|
|
4
|
-
require 'yaml'
|
|
2
|
+
autoload :YAML, 'yaml'
|
|
5
3
|
|
|
6
4
|
# YAMLSaver saves and loads cookies in the YAML format. It can load a
|
|
7
5
|
# YAML file saved by Mechanize, but the saving format is not
|
|
@@ -74,13 +72,9 @@ class HTTP::CookieJar::YAMLSaver < HTTP::CookieJar::AbstractSaver
|
|
|
74
72
|
{}
|
|
75
73
|
end
|
|
76
74
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
else
|
|
82
|
-
def load_yaml(yaml)
|
|
83
|
-
YAML.load(yaml)
|
|
84
|
-
end
|
|
75
|
+
def load_yaml(yaml)
|
|
76
|
+
YAML.safe_load(yaml, :permitted_classes => %w[Time HTTP::Cookie Mechanize::Cookie DomainName], :aliases => true)
|
|
77
|
+
rescue NoMethodError # ruby < 2.0, no safe_load
|
|
78
|
+
YAML.load(yaml)
|
|
85
79
|
end
|
|
86
80
|
end
|
data/lib/http/cookie_jar.rb
CHANGED
|
@@ -1,31 +1,12 @@
|
|
|
1
1
|
# :markup: markdown
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
require "http/cookie"
|
|
3
4
|
|
|
4
5
|
##
|
|
5
6
|
# This class is used to manage the Cookies that have been returned from
|
|
6
7
|
# any particular website.
|
|
7
8
|
|
|
8
9
|
class HTTP::CookieJar
|
|
9
|
-
class << self
|
|
10
|
-
def const_missing(name)
|
|
11
|
-
case name.to_s
|
|
12
|
-
when /\A([A-Za-z]+)Store\z/
|
|
13
|
-
file = 'http/cookie_jar/%s_store' % $1.downcase
|
|
14
|
-
when /\A([A-Za-z]+)Saver\z/
|
|
15
|
-
file = 'http/cookie_jar/%s_saver' % $1.downcase
|
|
16
|
-
end
|
|
17
|
-
begin
|
|
18
|
-
require file
|
|
19
|
-
rescue LoadError
|
|
20
|
-
raise NameError, 'can\'t resolve constant %s; failed to load %s' % [name, file]
|
|
21
|
-
end
|
|
22
|
-
if const_defined?(name)
|
|
23
|
-
const_get(name)
|
|
24
|
-
else
|
|
25
|
-
raise NameError, 'can\'t resolve constant %s after loading %s' % [name, file]
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
10
|
|
|
30
11
|
attr_reader :store
|
|
31
12
|
|
|
@@ -156,7 +137,7 @@ class HTTP::CookieJar
|
|
|
156
137
|
block_given? or return enum_for(__method__, uri)
|
|
157
138
|
|
|
158
139
|
if uri
|
|
159
|
-
uri =
|
|
140
|
+
uri = HTTP::Cookie::URIParser.parse(uri)
|
|
160
141
|
return self unless URI::HTTP === uri && uri.host
|
|
161
142
|
end
|
|
162
143
|
|
|
@@ -342,3 +323,6 @@ class HTTP::CookieJar
|
|
|
342
323
|
self
|
|
343
324
|
end
|
|
344
325
|
end
|
|
326
|
+
|
|
327
|
+
require 'http/cookie_jar/abstract_store'
|
|
328
|
+
require 'http/cookie_jar/abstract_saver'
|
metadata
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: http-cookie
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Akinori MUSHA
|
|
8
8
|
- Aaron Patterson
|
|
9
9
|
- Eric Hodel
|
|
10
10
|
- Mike Dalessio
|
|
11
|
-
autorequire:
|
|
12
11
|
bindir: bin
|
|
13
12
|
cert_chain: []
|
|
14
|
-
date:
|
|
13
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
15
14
|
dependencies:
|
|
16
15
|
- !ruby/object:Gem::Dependency
|
|
17
16
|
name: domain_name
|
|
@@ -31,14 +30,14 @@ dependencies:
|
|
|
31
30
|
name: sqlite3
|
|
32
31
|
requirement: !ruby/object:Gem::Requirement
|
|
33
32
|
requirements:
|
|
34
|
-
- - "
|
|
33
|
+
- - ">="
|
|
35
34
|
- !ruby/object:Gem::Version
|
|
36
35
|
version: '1.3'
|
|
37
36
|
type: :development
|
|
38
37
|
prerelease: false
|
|
39
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
39
|
requirements:
|
|
41
|
-
- - "
|
|
40
|
+
- - ">="
|
|
42
41
|
- !ruby/object:Gem::Version
|
|
43
42
|
version: '1.3'
|
|
44
43
|
- !ruby/object:Gem::Dependency
|
|
@@ -124,21 +123,17 @@ email:
|
|
|
124
123
|
executables: []
|
|
125
124
|
extensions: []
|
|
126
125
|
extra_rdoc_files:
|
|
127
|
-
- README.md
|
|
128
126
|
- LICENSE.txt
|
|
127
|
+
- README.md
|
|
129
128
|
files:
|
|
130
|
-
- ".github/workflows/ci.yml"
|
|
131
|
-
- ".gitignore"
|
|
132
129
|
- CHANGELOG.md
|
|
133
|
-
- Gemfile
|
|
134
130
|
- LICENSE.txt
|
|
135
131
|
- README.md
|
|
136
|
-
- Rakefile
|
|
137
|
-
- http-cookie.gemspec
|
|
138
132
|
- lib/http-cookie.rb
|
|
139
133
|
- lib/http/cookie.rb
|
|
140
134
|
- lib/http/cookie/ruby_compat.rb
|
|
141
135
|
- lib/http/cookie/scanner.rb
|
|
136
|
+
- lib/http/cookie/uri_parser.rb
|
|
142
137
|
- lib/http/cookie/version.rb
|
|
143
138
|
- lib/http/cookie_jar.rb
|
|
144
139
|
- lib/http/cookie_jar/abstract_saver.rb
|
|
@@ -147,16 +142,10 @@ files:
|
|
|
147
142
|
- lib/http/cookie_jar/hash_store.rb
|
|
148
143
|
- lib/http/cookie_jar/mozilla_store.rb
|
|
149
144
|
- lib/http/cookie_jar/yaml_saver.rb
|
|
150
|
-
- test/helper.rb
|
|
151
|
-
- test/mechanize.yml
|
|
152
|
-
- test/simplecov_start.rb
|
|
153
|
-
- test/test_http_cookie.rb
|
|
154
|
-
- test/test_http_cookie_jar.rb
|
|
155
145
|
homepage: https://github.com/sparklemotion/http-cookie
|
|
156
146
|
licenses:
|
|
157
147
|
- MIT
|
|
158
148
|
metadata: {}
|
|
159
|
-
post_install_message:
|
|
160
149
|
rdoc_options: []
|
|
161
150
|
require_paths:
|
|
162
151
|
- lib
|
|
@@ -171,13 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
171
160
|
- !ruby/object:Gem::Version
|
|
172
161
|
version: '0'
|
|
173
162
|
requirements: []
|
|
174
|
-
rubygems_version:
|
|
175
|
-
signing_key:
|
|
163
|
+
rubygems_version: 4.0.6
|
|
176
164
|
specification_version: 4
|
|
177
165
|
summary: A Ruby library to handle HTTP Cookies based on RFC 6265
|
|
178
|
-
test_files:
|
|
179
|
-
- test/helper.rb
|
|
180
|
-
- test/mechanize.yml
|
|
181
|
-
- test/simplecov_start.rb
|
|
182
|
-
- test/test_http_cookie.rb
|
|
183
|
-
- test/test_http_cookie_jar.rb
|
|
166
|
+
test_files: []
|
data/.github/workflows/ci.yml
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- master
|
|
7
|
-
pull_request:
|
|
8
|
-
branches:
|
|
9
|
-
- "*"
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
test:
|
|
13
|
-
strategy:
|
|
14
|
-
fail-fast: false
|
|
15
|
-
matrix:
|
|
16
|
-
os: [ubuntu]
|
|
17
|
-
# We still kind of support Ruby 1.8.7
|
|
18
|
-
ruby: [2.7, "3.0", 3.1, head, jruby]
|
|
19
|
-
|
|
20
|
-
name: >-
|
|
21
|
-
${{matrix.os}}:ruby-${{matrix.ruby}}
|
|
22
|
-
runs-on: ${{matrix.os}}-latest
|
|
23
|
-
continue-on-error: ${{matrix.ruby == 'head' || matrix.ruby == 'jruby'}}
|
|
24
|
-
|
|
25
|
-
steps:
|
|
26
|
-
- name: Check out
|
|
27
|
-
uses: actions/checkout@v2
|
|
28
|
-
|
|
29
|
-
- name: Set up ruby and bundle
|
|
30
|
-
uses: ruby/setup-ruby@v1
|
|
31
|
-
with:
|
|
32
|
-
ruby-version: ${{matrix.ruby}}
|
|
33
|
-
bundler-cache: true
|
|
34
|
-
|
|
35
|
-
- name: Run rake
|
|
36
|
-
run: |
|
|
37
|
-
bundle exec rake
|
data/.gitignore
DELETED
data/Gemfile
DELETED