lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev prelim config-file cookie accept/reject patch to dev19


From: brian j. pardy
Subject: lynx-dev prelim config-file cookie accept/reject patch to dev19
Date: Wed, 5 Aug 1998 12:43:41 -0700

Okay, after a bit of messing around, here's a preliminary patch to add
config-file based auto-accept/reject of cookies. Right now it's only
working for lynx.cfg, and will not work properly from .lynxrc, I'm working
on that. I wanted to get the patch out for others to play with.

I'm not sure yet why the way I'm doing the read from .lynxrc is failing,
it may or may not have something to do with the fact that I haven't
applied Bela's working LYstrsep() patch yet.


In this patch:

    * rename eat_all_cookies to accept_all_cookies everywhere
    * added ACCEPT_ALL_COOKIES lines to the dist lynx.cfg --
      this conflicts with LP's "2.8.1dev.19 typo & lynx.man/lynx.hlp/
      lynx.cfg fix" patch -- his adds the EAT_ALL_COOKIES option to 
      lynx.cfg (with the appropriate description), this should be the
      only problem there.
    * added COOKIE_ACCEPT_DOMAINS and COOKIE_REJECT_DOMAINS to lynx.cfg.
      These are comma delimited lists of the domains to handle
    * added cookie_add_acceptlist and cookie_add_rejectlist to LYCookie.c,
      which are passed the list of domains from lynx.cfg and add them to
      the global cookie list. These may be subject to change, as I might
      not be handling the LYstrsep() right -- it works with dev19's
      LYstrsep(), but hasn't been tested with Bela's...
    * added a big ugly ifdef'd out section to LYrcFile.c with what I have
      so far on the .lynxrc handling of COOKIE_{ACCEPT,REJECT}_DOMAINS.
      Don't use it. Makes nasty segfaults.

It all does seem to work, though. If a domain is specified in both
COOKIE_ACCEPT_DOMAINS and COOKIE_REJECT_DOMAINS, reject will take
precedence, because it's parsed after accept. 

Should patch cleanly to stock dev19.

diff -cr lynx2-8-1/lynx.cfg lynx2-8-1.bri/lynx.cfg
*** lynx2-8-1/lynx.cfg  Fri Jul 24 20:01:03 1998
--- lynx2-8-1.bri/lynx.cfg      Fri Jul 31 23:00:42 1998
***************
*** 735,740 ****
--- 735,746 ----
  #
  #SET_COOKIES:TRUE
  
+ # If ACCEPT_ALL_COOKIES is set TRUE, Lynx will accept cookies from all 
+ # domains with no user interaction.
+ # The default is defined in userdefs.h and can be overriden here, 
+ # and/or toggled via the -accept_all_cookies command line switch.
+ #ACCEPT_ALL_COOKIES:FALSE
+ 
  # VMS:
  #=====
  # The mail command and qualifiers are defined in userdefs.h.  Lynx
diff -cr lynx2-8-1/src/HTAlert.c lynx2-8-1.bri/src/HTAlert.c
*** lynx2-8-1/src/HTAlert.c     Fri Jul 31 02:34:41 1998
--- lynx2-8-1.bri/src/HTAlert.c Fri Jul 31 23:07:27 1998
***************
*** 435,447 ****
        namelen = (int)(percentage*(float)namelen);
        valuelen = (int)(percentage*(float)valuelen);
      }
!     if(!LYEatAllCookies) {
        sprintf(message, ADVANCED_COOKIE_CONFIRMATION,
                server, namelen, name, valuelen, value);
        _statusline(message);
      }
      while (1) {
!       if(!LYEatAllCookies) {
            ch = LYgetch();
        } else {
            ch = 'A';
--- 435,447 ----
        namelen = (int)(percentage*(float)namelen);
        valuelen = (int)(percentage*(float)valuelen);
      }
!     if(!LYAcceptAllCookies) {
        sprintf(message, ADVANCED_COOKIE_CONFIRMATION,
                server, namelen, name, valuelen, value);
        _statusline(message);
      }
      while (1) {
!       if(!LYAcceptAllCookies) {
            ch = LYgetch();
        } else {
            ch = 'A';
diff -cr lynx2-8-1/src/LYCookie.c lynx2-8-1.bri/src/LYCookie.c
*** lynx2-8-1/src/LYCookie.c    Fri Jul 31 02:34:41 1998
--- lynx2-8-1.bri/src/LYCookie.c        Wed Aug  5 00:09:49 1998
***************
*** 2435,2440 ****
--- 2435,2532 ----
      return(HT_LOADED);
  }
  
+ /* cookie_add_acceptlist
+  *   is passed a comma delimited string of domains (with leading '.')
+  *   to add to the "always accept" list for cookies.
+  */
+ 
+ PUBLIC void cookie_add_acceptlist ARGS1(
+         CONST char *,   acceptdomains)
+ {
+     domain_entry *de = NULL;
+     char **domain1;
+     char **origstr;
+ 
+     if (domain_list == NULL) {
+         atexit(LYCookieJar_free);
+         domain_list = HTList_new();
+         total_cookies = 0;
+     }
+ 
+     *origstr = (char *)acceptdomains;
+ 
+     for(;(*domain1 = LYstrsep(origstr, ",")) != NULL;)
+         if(**domain1 != '\0') {
+             de = (domain_entry *)calloc(1, sizeof(domain_entry));
+ 
+             if (de == NULL)
+                     outofmem(__FILE__, "cookie_accept_domains");
+ 
+             de->bv = ACCEPT_ALWAYS;
+ 
+             StrAllocCopy(de->domain, *domain1);
+             HTList_addObject(domain_list, de);
+         }
+ 
+     /* then one last one, cos that's how LYstrsep() works */
+ 
+     de = (domain_entry *)calloc(1, sizeof(domain_entry));
+ 
+     if (de == NULL)
+             outofmem(__FILE__, "cookie_accept_domains");
+ 
+     de->bv = ACCEPT_ALWAYS;
+ 
+     StrAllocCopy(de->domain, *origstr);
+     HTList_addObject(domain_list, de);
+ }
+ 
+ /* cookie_add_rejectlist
+  *   is passed a comma delimited string of domains (with leading '.')
+  *   to add to the "always reject" list for cookies.
+  */
+ 
+ PUBLIC void cookie_add_rejectlist ARGS1(
+         CONST char *,   rejectdomains)
+ {
+     domain_entry *de = NULL;
+     char **domain1;
+     char **origstr;
+ 
+     if (domain_list == NULL) {
+         atexit(LYCookieJar_free);
+         domain_list = HTList_new();
+         total_cookies = 0;
+     }
+ 
+     *origstr = (char *)rejectdomains;
+ 
+     for(;(*domain1 = LYstrsep(origstr, ",")) != NULL;)
+         if(**domain1 != '\0') {
+             de = (domain_entry *)calloc(1, sizeof(domain_entry));
+ 
+             if (de == NULL)
+                     outofmem(__FILE__, "cookie_reject_domains");
+ 
+             de->bv = REJECT_ALWAYS;
+ 
+             StrAllocCopy(de->domain, *domain1);
+             HTList_addObject(domain_list, de);
+         }
+ 
+     /* then one last one, cos that's how LYstrsep() works */
+ 
+     de = (domain_entry *)calloc(1, sizeof(domain_entry));
+ 
+     if (de == NULL)
+             outofmem(__FILE__, "cookie_reject_domains");
+ 
+     de->bv = REJECT_ALWAYS;
+ 
+     StrAllocCopy(de->domain, *origstr);
+     HTList_addObject(domain_list, de);
+ }
+ 
  #ifdef GLOBALDEF_IS_MACRO
  #define _LYCOOKIE_C_GLOBALDEF_1_INIT { "LYNXCOOKIE",LYHandleCookies,0}
  GLOBALDEF (HTProtocol,LYLynxCookies,_LYCOOKIE_C_GLOBALDEF_1_INIT);
diff -cr lynx2-8-1/src/LYGlobalDefs.h lynx2-8-1.bri/src/LYGlobalDefs.h
*** lynx2-8-1/src/LYGlobalDefs.h        Fri Jul 31 02:34:41 1998
--- lynx2-8-1.bri/src/LYGlobalDefs.h    Tue Aug  4 18:29:23 1998
***************
*** 285,291 ****
  extern int LYStatusLine;              /* Line for statusline() or -1   */
  extern BOOLEAN LYCollapseBRs;         /* Collapse serial BRs?          */
  extern BOOLEAN LYSetCookies;          /* Process Set-Cookie headers?   */
! extern BOOLEAN LYEatAllCookies;         /* accept ALL cookies?          */
  extern char *XLoadImageCommand;               /* Default image viewer for X   
 */
  #ifdef USE_EXTERNALS
  extern BOOLEAN no_externals; /* don't allow the use of externals */
--- 285,293 ----
  extern int LYStatusLine;              /* Line for statusline() or -1   */
  extern BOOLEAN LYCollapseBRs;         /* Collapse serial BRs?          */
  extern BOOLEAN LYSetCookies;          /* Process Set-Cookie headers?   */
! extern BOOLEAN LYAcceptAllCookies;      /* accept ALL cookies?          */
! extern char *LYCookieAcceptDomains;     /* domains to accept all cookies */
! extern char *LYCookieRejectDomains;     /* domains to reject all cookies */
  extern char *XLoadImageCommand;               /* Default image viewer for X   
 */
  #ifdef USE_EXTERNALS
  extern BOOLEAN no_externals; /* don't allow the use of externals */
diff -cr lynx2-8-1/src/LYMain.c lynx2-8-1.bri/src/LYMain.c
*** lynx2-8-1/src/LYMain.c      Fri Jul 31 02:34:41 1998
--- lynx2-8-1.bri/src/LYMain.c  Tue Aug  4 18:29:42 1998
***************
*** 336,342 ****
  PUBLIC int LYStatusLine = -1;          /* Line for statusline() if > -1 */
  PUBLIC BOOLEAN LYCollapseBRs = COLLAPSE_BR_TAGS;  /* Collapse serial BRs? */
  PUBLIC BOOLEAN LYSetCookies = SET_COOKIES; /* Process Set-Cookie headers? */
! PUBLIC BOOLEAN LYEatAllCookies = EAT_ALL_COOKIES; /* take all cookies?    */
  PUBLIC char *XLoadImageCommand = NULL;        /* Default image viewer for X */
  PUBLIC BOOLEAN LYNoISMAPifUSEMAP = FALSE; /* Omit ISMAP link if MAP present? 
*/
  PUBLIC int LYHiddenLinks = HIDDENLINKS_SEPARATE; /* Show hidden links? */
--- 336,344 ----
  PUBLIC int LYStatusLine = -1;          /* Line for statusline() if > -1 */
  PUBLIC BOOLEAN LYCollapseBRs = COLLAPSE_BR_TAGS;  /* Collapse serial BRs? */
  PUBLIC BOOLEAN LYSetCookies = SET_COOKIES; /* Process Set-Cookie headers? */
! PUBLIC BOOLEAN LYAcceptAllCookies = ACCEPT_ALL_COOKIES; /* take all cookies? 
*/
! PUBLIC char *LYCookieAcceptDomains = NULL; /* domains to accept all cookies */
! PUBLIC char *LYCookieRejectDomains = NULL; /* domains to reject all cookies */
  PUBLIC char *XLoadImageCommand = NULL;        /* Default image viewer for X */
  PUBLIC BOOLEAN LYNoISMAPifUSEMAP = FALSE; /* Omit ISMAP link if MAP present? 
*/
  PUBLIC int LYHiddenLinks = HIDDENLINKS_SEPARATE; /* Show hidden links? */
***************
*** 2525,2530 ****
--- 2527,2536 ----
  
  static Parse_Args_Type Arg_Table [] =
  {
+    PARSE_SET(
+       "accept_all_cookies", SET_ARG,          &LYAcceptAllCookies,
+       "\naccepts all cookies"
+    ),
     PARSE_FUN(
        "anonymous",    FUNCTION_ARG,   anonymous_fun,
        "used to specify the anonymous account"
***************
*** 2607,2616 ****
     PARSE_FUN(
        "dump",         FUNCTION_ARG,           dump_output_fun,
        "dump the first file to stdout and exit"
-    ),
-    PARSE_SET(
-       "eat_all_cookies", SET_ARG,             &LYEatAllCookies,
-       "accepts all cookies"
     ),
     PARSE_FUN(
        "editor",       NEED_FUNCTION_ARG,      editor_fun,
--- 2613,2618 ----
diff -cr lynx2-8-1/src/LYReadCFG.c lynx2-8-1.bri/src/LYReadCFG.c
*** lynx2-8-1/src/LYReadCFG.c   Fri Jul 31 02:34:41 1998
--- lynx2-8-1.bri/src/LYReadCFG.c       Wed Aug  5 12:32:08 1998
***************
*** 787,792 ****
--- 787,793 ----
  
  static Config_Type Config_Table [] =
  {
+      PARSE_SET("accept_all_cookies", CONF_BOOL, LYAcceptAllCookies),
       PARSE_INT("alertsecs", CONF_INT, AlertSecs),
       PARSE_SET("always_resubmit_posts", CONF_BOOL, LYresubmit_posts),
  #ifdef EXEC_LINKS
***************
*** 806,811 ****
--- 807,814 ----
  #ifdef USE_COLOR_TABLE
       PARSE_FUN("color", CONF_FUN, color_fun),
  #endif
+      PARSE_STR("cookie_accept_domains", CONF_STR, LYCookieAcceptDomains),
+      PARSE_STR("cookie_reject_domains", CONF_STR, LYCookieRejectDomains),
       PARSE_ENV("cso_proxy", CONF_ENV, 0 ),
  #ifdef VMS
       PARSE_STR("CSWING_PATH", CONF_STR, LYCSwingPath),
***************
*** 823,829 ****
       PARSE_FUN("dired_menu", CONF_FUN, dired_menu_fun),
  #endif
       PARSE_ADD("downloader", CONF_ADD_ITEM, downloaders),
-      PARSE_SET("eat_all_cookies", CONF_BOOL, LYEatAllCookies),
       PARSE_SET("emacs_keys_always_on", CONF_BOOL, emacs_keys),
       PARSE_SET("enable_scrollback", CONF_BOOL, enable_scrollback),
  #ifdef USE_EXTERNALS
--- 826,831 ----
***************
*** 1162,1166 ****
--- 1164,1182 ----
            }
            cur_download = cur_download->next;
        }
+     }
+ 
+     /*
+      * If any COOKIE_{ACCEPT,REJECT}_DOMAINS have been defined, 
+      * process them. These are comma delimited lists of 
+      * domains, with leading '.'. - BJP
+      */
+ 
+     if (LYCookieAcceptDomains != NULL) {
+         cookie_add_acceptlist(LYCookieAcceptDomains);
+     }
+ 
+     if (LYCookieRejectDomains != NULL) {
+         cookie_add_rejectlist(LYCookieRejectDomains);
      }
  }
diff -cr lynx2-8-1/src/LYrcFile.c lynx2-8-1.bri/src/LYrcFile.c
*** lynx2-8-1/src/LYrcFile.c    Fri Jul 31 02:34:41 1998
--- lynx2-8-1.bri/src/LYrcFile.c        Wed Aug  5 12:23:03 1998
***************
*** 426,448 ****
            }
  #endif /* DIRED_SUPPORT */
  
!       /*
!        * eat all cookies? i think it should work user-by-user.
!        *  -BJP
         */
!       } else if ((cp = LYstrstr(line_buffer, "eat_all_cookies")) != NULL &&
                   cp-line_buffer < number_sign) {
            if((cp2 = (char *)strchr(cp,'=')) != NULL)
                cp = cp2 + 1;
            while (isspace(*cp))
                cp++; /* get rid of spaces */
            if (LYstrstr(cp,"TRUE") != NULL) {
!               LYEatAllCookies = TRUE;
            } else {
!               LYEatAllCookies = FALSE;
            }
-       /* BJP */
  
  
        /*
         *  User mode.
--- 426,476 ----
            }
  #endif /* DIRED_SUPPORT */
  
!       /* 
!        *  Accept cookies from all domains?
         */
!       } else if ((cp = LYstrstr(line_buffer, "accept_all_cookies")) != NULL &&
                   cp-line_buffer < number_sign) {
            if((cp2 = (char *)strchr(cp,'=')) != NULL)
                cp = cp2 + 1;
            while (isspace(*cp))
                cp++; /* get rid of spaces */
            if (LYstrstr(cp,"TRUE") != NULL) {
!               LYAcceptAllCookies = TRUE;
            } else {
!               LYAcceptAllCookies = FALSE;
            }
  
+ #ifdef THIS_DOESNT_WORK_YET_DONT_USE_IT
+ 
+         /* 
+          * Accept all cookies from certain domains?
+          */
+         } else if ((cp = LYstrstr(line_buffer, "cookie_accept_domains")) 
+                 != NULL && cp-line_buffer < number_sign) {
+             if((cp2 = (char *)strchr(cp,'=')) != NULL)
+                 cp = cp2 + 1;
+             while (isspace(*cp))
+                 cp++; /* get rid of spaces */
+             if (LYstrstr(cp,NULL) != NULL) {
+ /*                 cookie_add_acceptlist(cp); */
+             }
+ 
+ 
+         /* 
+          * Reject all cookies from certain domains?
+          */
+         } else if ((cp = LYstrstr(line_buffer, "cookie_reject_domains")) 
+                 != NULL && cp-line_buffer < number_sign) {
+             if((cp2 = (char *)strchr(cp,'=')) != NULL)
+                 cp = cp2 + 1;
+             while (isspace(*cp))
+                 cp++; /* get rid of spaces */
+             if (LYstrstr(cp,NULL) != NULL) {
+ /*                 cookie_add_rejectlist(cp); */
+             }
+ 
+ #endif
  
        /*
         *  User mode.
diff -cr lynx2-8-1/userdefs.h lynx2-8-1.bri/userdefs.h
*** lynx2-8-1/userdefs.h        Fri Jul 31 02:34:41 1998
--- lynx2-8-1.bri/userdefs.h    Fri Jul 31 23:01:36 1998
***************
*** 819,831 ****
  #define SET_COOKIES TRUE
  
  /******************************* 
!  * If EAT_ALL_COOKIES is set TRUE, and SET_COOKIES is TRUE, lynx will accept 
!  * all cookies. 
   * 
   * The default defined here can be changed in lynx.cfg, and .lynxrc, or 
!  * specified with the -eat_all_cookies command line switch. 
   */ 
! #define EAT_ALL_COOKIES FALSE 
   
  
  /****************************************************************
--- 819,831 ----
  #define SET_COOKIES TRUE
  
  /******************************* 
!  * If ACCEPT_ALL_COOKIES is set TRUE, and SET_COOKIES is TRUE, Lynx will 
!  * accept all cookies. 
   * 
   * The default defined here can be changed in lynx.cfg, and .lynxrc, or 
!  * toggled via the -accept_all_cookies command line switch. 
   */ 
! #define ACCEPT_ALL_COOKIES FALSE 
   
  
  /****************************************************************

-- 
QOTD:
        All I want is a little more than I'll ever get.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]