Commit graph

225 commits

Author SHA1 Message Date
Akinori MUSHA
5bdb8f41ae Cookie#new prefers downcased symbols for keywords.
Test warnings.
2013-04-16 08:44:48 +09:00
Akinori MUSHA
c293005676 Bump VERSION to 1.0.0.pre12. 2013-04-16 02:44:26 +09:00
Akinori MUSHA
8ae076d9ea Fix the compatibility code to support Syck. 2013-04-16 01:39:09 +09:00
Akinori MUSHA
fcdaddcbe6 Emit a proper message when try_convert() fails. 2013-04-16 01:38:05 +09:00
Akinori MUSHA
b02e800dfa Comment out unused/advisory bits to gain coverage. 2013-04-16 00:54:56 +09:00
Akinori MUSHA
10ddb688df Inhibit cloning MozillaStore. 2013-04-16 00:38:47 +09:00
Akinori MUSHA
d806955f57 Fix hand-made autoloading to allow directly referencing MozillaStore. 2013-04-16 00:37:10 +09:00
Akinori MUSHA
ded02f8327 Make MozillaStore#close actually "work" by closing open statements.
Add a finalizer to MozillaStore also, which automatically closes the
SQLite3 database.
2013-04-16 00:04:54 +09:00
Akinori MUSHA
e9230a00c1 Add tests for MozillaStore#upgrade_database and fix its bugs. 2013-04-16 00:03:03 +09:00
Akinori MUSHA
25dd32219f MozillaStore#close: Do not call SQLite3::Database#close if already closed. 2013-04-15 23:57:35 +09:00
Akinori MUSHA
d44218c2e2 Cookie#acceptable? should not raise ArgumentError when it takes no argument.
Let CookieJar#add convert RuntimeError raised by acceptable? to
ArgumentError.
2013-04-15 10:29:07 +09:00
Akinori MUSHA
ea45ee3b38 Bump the version to 1.0.0.pre11. 2013-04-15 10:16:28 +09:00
Akinori MUSHA
03627aa42a Fix Hash.try_convert. 2013-04-15 09:33:47 +09:00
Akinori MUSHA
28458101b6 HTTP::Cookie.set_cookie_value: Don't take an origin argument. 2013-04-15 08:54:09 +09:00
Akinori MUSHA
88e3f28591 Directly define String#try_convert and Hash#try_convert in ruby 1.8. 2013-04-14 18:22:30 +09:00
Akinori MUSHA
39861d2dbb Fix time value validation. 2013-04-14 13:47:49 +09:00
Akinori MUSHA
9a6b18463b scan_name never returns nil because RE_NAME matches an empty string. 2013-04-14 13:29:08 +09:00
Akinori MUSHA
6ec66d11ed Restore and improve compatibility with ruby 1.8. 2013-04-14 13:01:37 +09:00
Akinori MUSHA
a1a130f156 CookieJar#parse: Use the block's return values to decide whether to add a cookie. 2013-04-14 12:10:28 +09:00
Akinori MUSHA
5478f3d9c9 Improve rdoc. 2013-04-14 11:49:40 +09:00
Akinori MUSHA
2e8fcb4a76 yaml_initialize: Initialize @origin to reduce warnings. 2013-04-13 13:04:54 +09:00
Akinori MUSHA
02587d67e0 Cookie.new: Deprecate un-downcased keywords. 2013-04-13 12:56:33 +09:00
Akinori MUSHA
e1857d76a4 Add Cookie.cookie_value and Cookie.cookie_value_to_hash. 2013-04-12 02:15:13 +09:00
Akinori MUSHA
82e65b4a9b Allow assigning nil to the cookie value to make an expiration cookie.
Cookie.new(): Make the value parameter can be omittable.
2013-04-12 02:13:08 +09:00
Akinori MUSHA
8c30527293 Update rdoc and comments. 2013-04-12 20:22:50 +09:00
Akinori MUSHA
f1fe763007 CookieJar#cookie(): Allow call without an argument. 2013-04-12 01:40:17 +09:00
Akinori MUSHA
53758d0a77 Omit expiration check in cookies(). Remove an unused variable. 2013-04-12 15:41:18 +09:00
Akinori MUSHA
a485e83ad9 Simply use cookie.domain instead of cookie.domain_name.hostname. 2013-04-12 01:19:49 +09:00
Akinori MUSHA
f3b8abdd8e Add CookieJar#delete(). 2013-04-12 01:19:39 +09:00
Akinori MUSHA
2ef3e42067 Add a note about the for_domain flag in the rdoc for CookieJar#add(). 2013-04-12 01:19:03 +09:00
Akinori MUSHA
787a0edbb9 Make use of Hash#fetch. 2013-04-11 21:18:25 +09:00
Akinori MUSHA
8649485f53 Improve rdoc. 2013-04-11 21:13:40 +09:00
Akinori MUSHA
57218cb858 HTTP::CookieJar#cookies: accessed_at is updated in the underlying store. 2013-04-11 21:12:53 +09:00
Akinori MUSHA
f0eb5d0cd8 Improve markups. 2013-04-08 00:03:04 +09:00
Akinori MUSHA
db2a4afff1 Bump VERSION to 1.0.0.pre10. 2013-04-07 23:10:25 +09:00
Akinori MUSHA
6689b3b7aa Drop support for obsolete attributes: version and comment. 2013-04-07 23:09:30 +09:00
Akinori MUSHA
9e46ce0d30 Cookie#max_age= should reject malformed strings. 2013-04-07 23:07:20 +09:00
Akinori MUSHA
dcf7f7e7a5 Avoid a bug of ruby 1.8. 2013-04-03 20:09:48 +09:00
Akinori MUSHA
726e2f89ea Emulate behavior of URI() of ruby >=1.9 where it raises ArgumentError. 2013-04-03 18:41:22 +09:00
Akinori MUSHA
9b4ce19873 Bump VERSION to 1.0.0.pre9. 2013-04-03 18:08:56 +09:00
Akinori MUSHA
7dba33bd40 Cookie#domain=: Fix handling of an empty string and let it accept nil. 2013-04-03 17:58:41 +09:00
Akinori MUSHA
ffabb614ad Perform acceptance check in CookieJar#add instead of origin=.
- Cookie#acceptable? is added, which is called by such methods as
  Cookie.parse and CookieJar#add.

- Cookie#origin= no longer raises ArgumentError just because it
  conflicts with the domain.

- Cookie#origin= raises ArgumentError if it is given an object that is
  not URI or string-like.
2013-04-03 17:57:27 +09:00
Akinori MUSHA
90ffce9aa6 Improve rdoc. 2013-04-03 17:29:08 +09:00
Akinori MUSHA
25630b35e7 Use case-when. 2013-04-02 23:34:44 +09:00
Akinori MUSHA
7ab0a15d78 Update rdoc. 2013-03-29 15:34:27 +09:00
Akinori MUSHA
48f5783ba5 origin=: Do not raise error if the new value is the same as the stock value. 2013-03-29 02:14:55 +09:00
Akinori MUSHA
5a78013d85 Bump the version to 1.0.0.pre8. 2013-03-29 01:58:43 +09:00
Akinori MUSHA
1c140c035d Add a utility shorthand method HTTP::CookieJar#parse. 2013-03-29 01:55:43 +09:00
Akinori MUSHA
dc65a98907 HTTP::Cookie.parse: Change the signature again.
I made the uri parameter optional when I introduced the origin
attribute, but on second thought it should always be given.

I'm making the origin parameter fixed and mandatory again, but this
time it comes next to set_cookie.  This order should look more natural
because the one that comes first is to be parsed.

Since Mechanize::Cookie.parse required the uri parameter to be a URI
object, backward compatibility is still possible.
2013-03-29 01:39:30 +09:00
Akinori MUSHA
ef7bdeefba Cookie#cookie_value too should quote values if necessary. 2013-03-28 22:06:19 +09:00
Akinori MUSHA
3131a46f14 Bump the version to 1.0.0.pre7. 2013-03-28 19:13:04 +09:00
Akinori MUSHA
26034253b1 Elaborate on the hash storage model. 2013-03-28 19:13:02 +09:00
Akinori MUSHA
4f526857aa Store special cookies properly.
"Special" cookies here mean those of public suffixes and IP addresses.
2013-03-28 19:10:14 +09:00
Akinori MUSHA
91b5184d96 Hold session cookies in an internal HashStore. 2013-03-28 19:10:14 +09:00
Akinori MUSHA
11a9df8559 Fix handling of the :for_domain option in HTTP::Cookie.new(). 2013-03-28 01:46:42 +09:00
Akinori MUSHA
add4a367fd Include MonitorMixin in store classes and make them thread-safe. 2013-03-28 01:05:22 +09:00
Akinori MUSHA
30e2915c1e Officially add AbstractStore#delete() as an API method. 2013-03-28 01:04:45 +09:00
Akinori MUSHA
19901a9d9c Edit rdoc. 2013-03-28 00:37:35 +09:00
Akinori MUSHA
a3a1acfee2 Even a host that equals a public suffix may not issue domain wide cookies.
This is described in RFC 6265 5.3.
2013-03-28 00:36:01 +09:00
Akinori MUSHA
c787b0b9dc Bump VERSION to 1.0.0.pre6. 2013-03-28 00:16:51 +09:00
Akinori MUSHA
e72b0fdbc5 YAMLServer#load: Add backward compatibility for reading YAML in the old format. 2013-03-28 00:13:32 +09:00
Akinori MUSHA
073d83b40c Cookie.new: Let max_age take precedence over expires. 2013-03-28 00:12:46 +09:00
Akinori MUSHA
fcb447164d Prefer __send__ to send. 2013-03-28 00:12:29 +09:00
Akinori MUSHA
8aa9ed9e6c Bump VERSION to 1.0.0.pre5. 2013-03-27 21:17:07 +09:00
Akinori MUSHA
c53579c231 Bump VERSION to 1.0.0.pre4. 2013-03-27 19:52:14 +09:00
Akinori MUSHA
eed7e57813 Use the cookie creation time as base time for Max-Age.
Now #expire returns created_at + max_age when expires is nil.

Cookie.parse: the :date keyword is renamed to :created_at, and the
value is set to in parsed cookies via #created_at.

In YAML serialization, #max_age is stored.
2013-03-27 19:50:30 +09:00
Akinori MUSHA
4512c333b4 MozillaStore: Add #filename, #close and #closed?. 2013-03-27 19:50:27 +09:00
Akinori MUSHA
a7575ae3df Improve documentation. 2013-03-27 18:17:56 +09:00
Akinori MUSHA
a0ea64da56 CookieJar.new: Pass the store class via a :store keyword. 2013-03-27 17:43:58 +09:00
Akinori MUSHA
b58736957d Bump VERSION to 1.0.0.pre3. 2013-03-27 16:10:11 +09:00
Akinori MUSHA
6fade20c59 Make GC threshold user specifiable. 2013-03-27 16:10:05 +09:00
Akinori MUSHA
69b3186666 Add MozillaStore. 2013-03-27 16:01:48 +09:00
Akinori MUSHA
bea9b1b502 each, cleanup: Fix the base date for expiration when the method starts.
This change is to remove an assumption that the clock is monotonic.
2013-03-27 15:10:03 +09:00
Akinori MUSHA
299bb24550 add(): Stop deleting an existing cookie when storing an expired cookie.
This is a backout of what I've done previously.  Expiration check is
better done in extraction where a user can optionally specify a base
date.

Add an internal method delete() to delete an existing cookie.
2013-03-27 14:58:22 +09:00
Akinori MUSHA
bd3ae6c1ae CookiestxtSaver: Hide HttpOnly cookies from old browsers.
This trick is the one that has been used in Mozilla before switching
the cookie database to SQLite.
2013-03-26 15:37:50 +09:00
Akinori MUSHA
8b78e3d1e4 CookiestxtSaver: Prefix the domain field with a dot if the domain flag is on.
The leading dot itself should be meaningless since there is the second
field to tell if the cookie is issued for a domain and that was the
reason I once removed it, but on second thought it doesn't hurt to put
one.
2013-03-26 15:37:50 +09:00
Akinori MUSHA
f2ea366de2 Add HTTP::Cookie#dot_domain. 2013-03-26 01:48:27 +09:00
Akinori MUSHA
f5bc5032dd No need to check validity here any more. 2013-03-26 01:43:19 +09:00
Akinori MUSHA
51da5e4c50 Do not touch and yield a cookie that should not be sent. 2013-03-26 01:43:06 +09:00
Akinori MUSHA
30920cae9c Bump VERSION to 1.0.0.pre2. 2013-03-23 02:03:17 +09:00
Akinori MUSHA
5b78957e19 Conform to RFC 6265 5.1.4 in that path=/a matches /a/* but not /ab.
Remove HTTP::Cookie.normalize_path and add HTTP::Cookie.path_match?
instead for comparison.
2013-03-23 02:02:56 +09:00
Akinori MUSHA
6dda359db1 Improve rdoc. 2013-03-23 00:37:21 +09:00
Akinori MUSHA
38f7e98f09 Replace compatibility errors with documentation.
Leave compatibility stuff to Mechanize itself and just keep
http-cookie clean.
2013-03-23 00:27:38 +09:00
Akinori MUSHA
ba3ea4cd33 Bump the version number high up to 1.0.0.pre1. 2013-03-21 17:56:08 +09:00
Akinori MUSHA
96dabc8288 Add 1.8 compatibility. 2013-03-21 17:31:05 +09:00
Akinori MUSHA
c442e8e0c8 The compatibility method clear! does not need to take arguments. 2013-03-21 17:30:25 +09:00
Akinori MUSHA
ddf74fee1e Rewrite the Set-Cookie header parser entirely.
The new parser is almost RFC 6265 compliant as the previous
implementation but has some extensions:

- It can parse double-quoted values with unsafe characters inside
  escaped with the backslash.

- It parses a date value of the expires attribute in the way the RFC
  describes, with an exception that it allows omission of the seconds
  field.  Some of the broken date representations that used to pass
  are now treated as error and ignored.

- It can parse a Set-Cookie value that contains multiple cookie
  definitions separated by comma, and commas put inside double quotes
  are not mistaken as definition separator.
2013-03-21 15:52:22 +09:00
Akinori MUSHA
b11aa95025 Initialize secure and httponly with false instead of nil. 2013-03-21 15:49:44 +09:00
Akinori MUSHA
6b6944b324 Add inspect. 2013-03-21 15:46:45 +09:00
Akinori MUSHA
66f37b20dd Rename expire to expire!, to reduce the risk of making a typo. 2013-03-21 15:46:45 +09:00
Akinori MUSHA
f04714741f Add expires_at as alias for expires. 2013-03-21 15:46:45 +09:00
Akinori MUSHA
ae0b3834e7 Make path= accept a string-like. 2013-03-21 15:46:45 +09:00
Akinori MUSHA
59370c79c3 Improve rdoc markups, migrating to Markdown. 2013-03-21 15:46:45 +09:00
Akinori MUSHA
5d0bc5f67d Disallow some more bad characters in name=/value=. 2013-03-21 15:46:45 +09:00
Akinori MUSHA
cc6780a5bc A relative path must be treated as the root path as per RFC 6265 5.1.4. 2013-03-21 15:46:45 +09:00
Akinori MUSHA
28eabedcd3 Use __send__() instead of send(). 2013-03-21 15:46:45 +09:00
Akinori MUSHA
b78271db6d Remove an obsolete part. 2013-03-21 15:46:45 +09:00
Akinori MUSHA
f14c1786cd Make expires and max_age affect each other and drop session=(). 2013-03-21 15:46:45 +09:00
Akinori MUSHA
1c7b660c85 Improve comments. 2013-03-21 15:46:45 +09:00
Akinori MUSHA
7d81c10914 A cookie value may be DQUOTE'd as per RFC 6265 2.2.
Escaping with the backslash character is not mentioned in the RFC but
the backslash character is not allowed here anyway, so just be nice
and support it for legacy applications.
2013-03-21 15:46:45 +09:00