aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshawn boles2010-09-08 22:36:13 -0700
committerGlenn Morris2010-09-08 22:36:13 -0700
commit966bb6c00556a2409178592ebd0207b010fa14af (patch)
treefb8a128f0fc2f44615a76003e8b7c70e22f2cee5
parent33bd47beb4a1157447a29f45167a0628f73224ec (diff)
downloademacs-966bb6c00556a2409178592ebd0207b010fa14af.tar.gz
emacs-966bb6c00556a2409178592ebd0207b010fa14af.zip
* lisp/url/url-cookie.el (url-cookie-expired-p): Simplify and fix. (Bug#6957)
-rw-r--r--lisp/url/ChangeLog4
-rw-r--r--lisp/url/url-cookie.el35
2 files changed, 10 insertions, 29 deletions
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index f7babefc876..0192987907c 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,7 @@
12010-09-09 shawn boles <shawn.boles@gmail.com> (tiny change)
2
3 * url-cookie.el (url-cookie-expired-p): Simplify and fix. (Bug#6957)
4
12010-07-26 Michael Albinus <michael.albinus@gmx.de> 52010-07-26 Michael Albinus <michael.albinus@gmx.de>
2 6
3 * url-http (url-http-parse-headers): Disable file name handlers at 7 * url-http (url-http-parse-headers): Disable file name handlers at
diff --git a/lisp/url/url-cookie.el b/lisp/url/url-cookie.el
index 75a1b218830..810e0e4eb58 100644
--- a/lisp/url/url-cookie.el
+++ b/lisp/url/url-cookie.el
@@ -24,7 +24,6 @@
24 24
25;;; Code: 25;;; Code:
26 26
27(require 'timezone)
28(require 'url-util) 27(require 'url-util)
29(require 'url-parse) 28(require 'url-parse)
30(eval-when-compile (require 'cl)) 29(eval-when-compile (require 'cl))
@@ -194,34 +193,12 @@ telling Microsoft that."
194 (setq url-cookie-storage (list (list domain tmp)))))))) 193 (setq url-cookie-storage (list (list domain tmp))))))))
195 194
196(defun url-cookie-expired-p (cookie) 195(defun url-cookie-expired-p (cookie)
197 (let* ( 196 "Returns true if COOKIE is expired.
198 (exp (url-cookie-expires cookie)) 197If COOKIE has an expiration date it is converted to seconds, adjusted to the client timezone and then compared against (float-time)."
199 (cur-date (and exp (timezone-parse-date (current-time-string)))) 198 (let* ((exp (url-cookie-expires cookie))
200 (exp-date (and exp (timezone-parse-date exp))) 199 (exp-time (and exp (float-time (date-to-time exp)))))
201 (cur-greg (and cur-date (timezone-absolute-from-gregorian 200 (if (not exp) nil (> (float-time) exp-time)))
202 (string-to-number (aref cur-date 1)) 201 )
203 (string-to-number (aref cur-date 2))
204 (string-to-number (aref cur-date 0)))))
205 (exp-greg (and exp (timezone-absolute-from-gregorian
206 (string-to-number (aref exp-date 1))
207 (string-to-number (aref exp-date 2))
208 (string-to-number (aref exp-date 0)))))
209 (diff-in-days (and exp (- cur-greg exp-greg)))
210 )
211 (cond
212 ((not exp) nil) ; No expiry == expires at browser quit
213 ((< diff-in-days 0) nil) ; Expires sometime after today
214 ((> diff-in-days 0) t) ; Expired before today
215 (t ; Expires sometime today, check times
216 (let* ((cur-time (timezone-parse-time (aref cur-date 3)))
217 (exp-time (timezone-parse-time (aref exp-date 3)))
218 (cur-norm (+ (* 360 (string-to-number (aref cur-time 2)))
219 (* 60 (string-to-number (aref cur-time 1)))
220 (* 1 (string-to-number (aref cur-time 0)))))
221 (exp-norm (+ (* 360 (string-to-number (aref exp-time 2)))
222 (* 60 (string-to-number (aref exp-time 1)))
223 (* 1 (string-to-number (aref exp-time 0))))))
224 (> (- cur-norm exp-norm) 1))))))
225 202
226(defun url-cookie-retrieve (host &optional localpart secure) 203(defun url-cookie-retrieve (host &optional localpart secure)
227 "Retrieve all the netscape-style cookies for a specified HOST and LOCALPART." 204 "Retrieve all the netscape-style cookies for a specified HOST and LOCALPART."