lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev [PATCH] remove extension to EXTERNAL command, extend CERN rules


From: Vlad Harchev
Subject: lynx-dev [PATCH] remove extension to EXTERNAL command, extend CERN rules support for mailto: URLs
Date: Sun, 25 Jun 2000 19:33:02 +0500 (SAMST)

 In the recent messages on the thread "[PATCH]", I stated that I changed my
mind (thanks to Mike Castle) on the usability of extension to the EXTERNAL
command. As everybody remembers, that extension allowed users to set some
actions defined by EXTERNAL setting as "default" handlers for URLs with that
pattern - i.e. the action would be invoked on the matching URL even if user
activated the link using right-arrow or enter key, not just '.'. The original
patch I posted had some flaws - it didn't support 'g', 'G', 'E' and
'x' commands. It turned out that CERN rules already provided functionality of
redirecting URLs to lynxexec: URL that allows invoking any programs (well, the
set of programs can be limited). Such support for redirecting URLs via CERN
rules is global and it covers all lynx commands. The only disavantage in
using CERN rules was inability to redirect mailto: URLs. 

 I fixed that problem with redirecting mailto: URLs and it seems that now it's
better to remove support for extended functionality of EXTERNAL setting, since
it duplicates functionality of CERN rules and it not finished (doesn't support 
'g', 'G', 'E' and 'x' commands).
 Here is a piece of lynx.cfg that tells lynx to handle all ftp:// links
using 'links' browser:
------------------
#this is needed to allow exec'ing programs
LOCAL_EXECUTION_LINKS_ON_BUT_NOT_REMOTE:TRUE

RULE:PermitRedirection ftp:*
#it's necessary to allow redirection

RULE:Redirect     ftp:*     "lynxprog:links ftp:*"
#the main rule
------------------

 Here is a patch that removes the effect of the patch extending functionality 
of EXTERNAL command, and allows redirecting of mailto: URLs. Documentation is
touched too.

 Notes: This patch is effectively 3 parts - one reverses modifications
made by previous patch, second touches /samples/cernrules.txt, third modifies
LYGetline.c to allow redirecting mailto: URLs using CERN rules.

 Best regards,
  -Vlad

diff -ru lynx2.8.4dev4-0/lynx.cfg lynx2.8.4dev4/lynx.cfg
--- lynx2.8.4dev4-0/lynx.cfg    Tue Jun 27 09:41:30 2000
+++ lynx2.8.4dev4/lynx.cfg      Sun Jun 25 18:18:12 2000
@@ -2801,13 +2801,12 @@
 #        via the external command.
 #
 # Restrictions can be imposed using -restrictions=externals at the Lynx command
-# line.  This will disallow all EXTERNAL lines in lynx.cfg that have FALSE in
-# the 3rd field (not counting the name of the setting).  TRUE lines will still
-# function.
+# line.  This will disallow all EXTERNAL lines in lynx.cfg that 
+# end in FALSE.  TRUE lines will still function.
 #
 # The lynx.cfg line is as follows:
 #
-# EXTERNAL:<url>:<command> %s:<norestriction>:<allow_for_activate>
+# EXTERNAL:<url>:<command> %s:<norestriction>
 #
 # <url> Any given URL.  This can be normal ones like ftp or http or it
 # can be one made up like mymail.
@@ -2821,12 +2820,6 @@
 # for certain externals to be enabled while restricting others.  TRUE means
 # a command will still function while Lynx is restricted.  WB
 #
-# <allow_for_activate> Setting this to TRUE allows the use of this command not
-# only when EXTERN key is pressed, but also when ACTIVATE command is invoked
-# (i.e activating the link with the given prefix will be equivalent to
-# pressing EXTERN key on it).  If this component of the line is absent, then
-# FALSE is assumed.
-# 
 # For invoking the command use the EXTERN key.  By default it is mapped
 # to '.' (if the feature is enabled), see the KEYMAP section above.
 #
diff -ru lynx2.8.4dev4-0/samples/cernrules.txt 
lynx2.8.4dev4/samples/cernrules.txt
--- lynx2.8.4dev4-0/samples/cernrules.txt       Thu Oct 21 19:56:48 1999
+++ lynx2.8.4dev4/samples/cernrules.txt Sun Jun 25 19:28:40 2000
@@ -536,7 +536,7 @@
 # Rules processing does not apply to all URL schemes.  Some are
 # handled differently from the generic access code, therefore rules
 # for such URLs will never be "seen".  This limitation applies at
-# least to lynxexec:, lynxprog:, mailto:, LYNXHIST:, LYNXMESSAGES:,
+# least to lynxexec:, lynxprog:, LYNXHIST:, LYNXMESSAGES:,
 # LYNXCFG:, and LYNXCOMPILEOPTS: URLs.  You shouldn't be tempted
 # to try to redirect most of these schemes anyway, but this also
 # makes it impossible to disable them with "Fail" rules.
diff -ru lynx2.8.4dev4-0/src/LYExtern.c lynx2.8.4dev4/src/LYExtern.c
--- lynx2.8.4dev4-0/src/LYExtern.c      Tue Jun 27 09:41:30 2000
+++ lynx2.8.4dev4/src/LYExtern.c        Sun Jun 25 18:21:34 2000
@@ -170,9 +170,7 @@
     HTEndParam(result, fmt, 1);
 }
 
-BOOL run_external ARGS2(
-    char *,    c,
-    BOOL,      only_overriders)
+void run_external ARGS1(char *, c)
 {
 #ifdef WIN_EX
     HANDLE handle;
@@ -184,10 +182,9 @@
 #endif
     char *cmdbuf = NULL;
     lynx_html_item_type *externals2 = 0;
-    int found = 0;
 
     if (externals == NULL)
-       return 0;
+       return;
 
 #ifdef WIN_EX                  /* 1998/01/26 (Mon) 09:16:13 */
     if (c == NULL) {
@@ -204,14 +201,12 @@
        CTRACE((tfp, "EXTERNAL: '%s' <==> '%s'\n", externals2->name, c));
 #endif
        if (externals2->command != 0
-         && !strncasecomp(externals2->name, c, strlen(externals2->name))
-         && (only_overriders ? externals2->override_primary_action : 1))
+         && !strncasecomp(externals2->name, c, strlen(externals2->name)))
        {
-           if (no_externals && !externals2->always_enabled && 
!only_overriders) {
+            if (no_externals && !externals2->always_enabled) { 
                HTUserMsg(EXTERNALS_DISABLED);
                break;
            }
-           ++found;
            /*  Too dangerous to leave any URL that may come along unquoted.
             *  They often contain '&', ';', and '?' chars, and who knows
             *  what else may occur.
@@ -376,6 +371,6 @@
     } /* end-for */
 
     FREE(cmdbuf);
-    return found;
+    return;
 }
 #endif /* USE_EXTERNALS */
diff -ru lynx2.8.4dev4-0/src/LYExtern.h lynx2.8.4dev4/src/LYExtern.h
--- lynx2.8.4dev4-0/src/LYExtern.h      Tue Jun 27 09:41:30 2000
+++ lynx2.8.4dev4/src/LYExtern.h        Sun Jun 25 18:21:43 2000
@@ -5,8 +5,7 @@
 #include <LYStructs.h>
 #endif /* LYSTRUCTS_H */
 
-/*returns TRUE if something matching was executed*/
-BOOL run_external PARAMS((char * c, BOOL only_overriders));
+void run_external PARAMS((char * c));
 char *string_short PARAMS((char * str, int cut_pos));
 
 #ifdef WIN_EX
diff -ru lynx2.8.4dev4-0/src/LYGetFile.c lynx2.8.4dev4/src/LYGetFile.c
--- lynx2.8.4dev4-0/src/LYGetFile.c     Tue Jun 27 09:41:30 2000
+++ lynx2.8.4dev4/src/LYGetFile.c       Tue Jun 27 11:43:00 2000
@@ -2,6 +2,9 @@
 #include <HTTP.h>
 #include <HTAnchor.h>      /* Anchor class */
 #include <HTAccess.h>
+#ifndef NO_RULES
+#include <HTRules.h>
+#endif
 #include <HTParse.h>
 #include <LYCurses.h>
 #include <GridText.h>
@@ -536,6 +539,19 @@
                        HTParentAnchor *tmpanchor;
                        CONST char *title;
                        char *tmptitle = NULL;
+                       
+#ifndef NO_RULES
+                       char* newurl = HTTranslate(doc->address);
+                       if (!newurl) {
+                           if (redirecting_url && strcmp(redirecting_url 
,doc->address)) {
+                               StrAllocCopy(doc->address,redirecting_url);
+                               goto Try_Redirected_URL;
+                           };
+                           FREE(redirecting_url);
+                       } else {
+                           FREE(newurl);//no need in it - it's just a copy
+                       };
+#endif                 
 
                        title = "";
                        if ((tmpanchor = HTAnchor_parent(
diff -ru lynx2.8.4dev4-0/src/LYMainLoop.c lynx2.8.4dev4/src/LYMainLoop.c
--- lynx2.8.4dev4-0/src/LYMainLoop.c    Tue Jun 27 09:41:30 2000
+++ lynx2.8.4dev4/src/LYMainLoop.c      Sun Jun 25 18:23:03 2000
@@ -1301,9 +1301,6 @@
                    return 0;
                }
 
-           if (run_external(links[curdoc.link].lname, TRUE))
-               return 0;
-
            /*
             *  Follow a normal link or anchor.
             */
@@ -2649,7 +2646,7 @@
 {
     if ((nlinks > 0) && (links[curdoc.link].lname != NULL))
     {
-       run_external(links[curdoc.link].lname, FALSE);
+       run_external(links[curdoc.link].lname);
        *refresh_screen = TRUE;
     }
 }
diff -ru lynx2.8.4dev4-0/src/LYReadCFG.c lynx2.8.4dev4/src/LYReadCFG.c
--- lynx2.8.4dev4-0/src/LYReadCFG.c     Tue Jun 27 09:41:30 2000
+++ lynx2.8.4dev4/src/LYReadCFG.c       Sun Jun 25 18:27:05 2000
@@ -165,7 +165,6 @@
     cur_item->name = NULL;
     cur_item->command = NULL;
     cur_item->always_enabled = FALSE;
-    cur_item->override_primary_action = FALSE;
 
     /*
      * Find first unescaped colon and process fields
@@ -197,13 +196,7 @@
            remove_backslashes(cur_item->command);
        }
        if (*next_colon++) {
-           colon = next_colon;
-           if ((next_colon = strchr(colon,':')) != 0)
-               *next_colon++ = '\0';           
-           cur_item->always_enabled = is_true(colon);
-           if (next_colon) {
-               cur_item->override_primary_action = is_true(next_colon);
-           }
+            cur_item->always_enabled = is_true(next_colon);
        }
     }
 }
diff -ru lynx2.8.4dev4-0/src/LYStructs.h lynx2.8.4dev4/src/LYStructs.h
--- lynx2.8.4dev4-0/src/LYStructs.h     Tue Jun 27 09:41:30 2000
+++ lynx2.8.4dev4/src/LYStructs.h       Sun Jun 25 18:24:09 2000
@@ -88,13 +88,6 @@
                                        * not to disable the printer
                                        * when the no_print option is on
                                        */
-    BOOL override_primary_action;      /* whether primary action will be
-                                       * overridden by this - e.g. this allows
-                                       * invoking user's MUA when mailto: link
-                                       * is activated using normal "activate"
-                                       * command. This field is only examined
-                                       * by code that handles EXTERNAL command.
-                                       */
 } lynx_html_item_type;
 
 /* for printer commands */


; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden

reply via email to

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