[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: w3m, cookie and google scholar



(I added the w3m list to CC but not to Reply-To since the list
is not open to people who don't subscribe to it, IIRC.)

Hi,

Could anyone in the w3m community look into the patch for cookie.c?
I tried it together with the one for w3m-cookie.el, and saw emacs-w3m
worked great with Google scholar.

>>>>> In [emacs-w3m : No.08943] Ren Lifeng wrote:

> 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.

Thank you very much for the patches.  I modified preferences in

http://scholar.google.com/scholar_preferences?hl=ja&lr=lang_ja&ie=UTF-8&output=search

and verified that they were restored next time I started emacs-w3m.
I also verified that w3m and emacs-w3m that weren't patched didn't
do so.  As soon as w3m developers act, I'm going to install the
patch for w3m-cookie.el.

BTW, could you write the ChangeLog entries by yourself?

Best regards,

> 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)