[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
w3m, cookie and google scholar
- From: Ren Lifeng <lfren@xxxxxxxxxxxxxx>
- Date: Wed, 15 Nov 2006 14:18:31 +0800
- X-ml-name: emacs-w3m
- X-mail-count: 08943
- References: <87ac377d7d.fsf@gforge.3322.org>
hi,
w3m users can't set preferences for google scholar with because google
send invalid "set-cookie" headers.
it sends
Set-Cookie: GSP=ID=fef3b1bf29568bb4; expires=Sun, 17-Jan-2038
19:14:07 GMT; path=/; domain=.scholar.google.com\r\n
with the leading dot, this cookie should be rejected according to rfc
2109 (see section 4.3.2).
although this is apparently google's fault, we' d better be pratical.
here is the patches to w3m/emacs-w3m to walk around this problem.
regards,
Ren lifeng
here is the patch. hope it will be helpful to others who want download
bibtex entry from google scholar.
Index: w3m-cookie.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m-cookie.el,v
retrieving revision 1.20
diff -u -r1.20 w3m-cookie.el
--- w3m-cookie.el 1 Feb 2006 11:44:32 -0000 1.20
+++ w3m-cookie.el 14 Nov 2006 21:54:41 -0000
@@ -155,9 +155,10 @@
(w3m-cookie-expires c))))
(push c expires)
(when (and (not (w3m-cookie-ignore c))
- (string-match (concat
- (regexp-quote (w3m-cookie-domain c)) "$")
- host)
+ (or (string= (concat "." host) (w3m-cookie-domain c))
+ (string-match (concat
+ (regexp-quote (w3m-cookie-domain c)) "$")
+ host))
(string-match (concat
"^" (regexp-quote (w3m-cookie-path c)))
path))
@@ -315,6 +316,8 @@
(cond
((string= host domain) ; Apparently netscape lets you do this
t)
+ ((string= (concat "." host) domain)
+ t)
((>= numdots mindots) ; We have enough dots in domain name
;; Need to check and make sure the host is actually _in_ the
;; domain it wants to set a cookie for though.
diff -u /home/rlf/prog/3rd/w3m/cookie.c /home/rlf/prog/source/w3m-0.5.1/cookie.c
--- /home/rlf/prog/3rd/w3m/cookie.c 2003-09-27 01:59:51.000000000 +0800
+++ /home/rlf/prog/source/w3m-0.5.1/cookie.c 2006-11-15 03:27:29.000000000 +0800
@@ -66,7 +66,10 @@
return domain_p;
}
/* [RFC 2109] s. 2, cases 2, 3 */
- else {
+ else if (strlen(host) - strlen(domain) == -1 &&
+ strcasecmp(host, &domain[1]) == 0)
+ return host; /* or domain */
+ else {
offset = (domain[0] != '.') ? 0 : strlen(host) - strlen(domain);
domain_p = &host[offset];
if (offset >= 0 && strcasecmp(domain_p, domain) == 0)
Diff finished. Wed Nov 15 05:51:55 2006
--