all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: shawn boles <shawn.boles@gmail.com>
To: 6957@debbugs.gnu.org
Subject: bug#6957: url-cookie-expired-p
Date: Tue, 31 Aug 2010 13:07:05 -0700	[thread overview]
Message-ID: <AANLkTiktdGTAynhkiUKOkBdMRMd40gsy2Mk3OdL8qU42@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1051 bytes --]

Hello,

Please forgive me if this list is not the correct recipient for this
message. If there is a better destination, I will be happy to send it
on.

I am working on a web services client that is mostly a wrapper around
URL Package. I am using GNU Emacs v.23.2. My client implementation
requires keeping tight rein on a session ID cookie. My sessions are
terminating abnormally. I believe I have tracked this issue to a bug
in url-cookie-expired-p.

If the cookie's expiration date is the same as today's date,
url-cookie-expired-p normalizes the times to seconds and compares the
difference. I believe the problem is in the normalization algorithm.
In pseudo-code, the current implementation does:

(+ (* 360 seconds) (* 60 minutes) (* 1 hours))

I believe this should be:

(+ (* 1 seconds) (* 60 minutes) (* 360 hours)).

As is, the result of the comparison is almost always dependent on the
number of seconds in the time strings. It is interesting how
frequently this mistaken comparison is correct.

I have attached a patch.

Thank you,

-shawn

[-- Attachment #2: url-cookie.el.patch --]
[-- Type: application/octet-stream, Size: 1032 bytes --]

--- /cygdrive/c/src/Emacs/emacs-23.2/emacs-23.2/lisp/url/url-cookie.el	2010-08-31 10:53:08.860091900 -0700
+++ url-cookie.el	2010-08-31 12:33:41.970367100 -0700
@@ -215,12 +215,12 @@
      (t					; Expires sometime today, check times
       (let* ((cur-time (timezone-parse-time (aref cur-date 3)))
 	     (exp-time (timezone-parse-time (aref exp-date 3)))
-	     (cur-norm (+ (* 360 (string-to-number (aref cur-time 2)))
+	     (cur-norm (+ (* 360 (string-to-number (aref cur-time 0)))
 			  (*  60 (string-to-number (aref cur-time 1)))
-			  (*   1 (string-to-number (aref cur-time 0)))))
-	     (exp-norm (+ (* 360 (string-to-number (aref exp-time 2)))
+			  (*   1 (string-to-number (aref cur-time 2)))))
+	     (exp-norm (+ (* 360 (string-to-number (aref exp-time 0)))
 			  (*  60 (string-to-number (aref exp-time 1)))
-			  (*   1 (string-to-number (aref exp-time 0))))))
+			  (*   1 (string-to-number (aref exp-time 2))))))
 	(> (- cur-norm exp-norm) 1))))))
 
 (defun url-cookie-retrieve (host &optional localpart secure)

             reply	other threads:[~2010-08-31 20:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-31 20:07 shawn boles [this message]
2010-08-31 22:51 ` bug#6957: url-cookie-expired-p Redux shawn boles
2010-08-31 23:39   ` Andreas Schwab
2010-09-01  0:43     ` shawn boles
2010-09-02 17:13 ` bug#6957: url-cookie-expired-p Redux (at last) shawn boles
2010-09-09  5:39   ` Glenn Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTiktdGTAynhkiUKOkBdMRMd40gsy2Mk3OdL8qU42@mail.gmail.com \
    --to=shawn.boles@gmail.com \
    --cc=6957@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.