lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev 2.8.2dev.15 patch 2 - news, mail


From: Klaus Weide
Subject: lynx-dev 2.8.2dev.15 patch 2 - news, mail
Date: Fri, 5 Feb 1999 18:04:50 -0600 (CST)

Here are some changes for news, and for recognizing some special
comments found in MHonArc archives, including the lynx-dev archive.
The last is specific to one archiver; someone suggested a while
ago that this should be configurable for various archiving packets.
Well I didn't go quite that far...

   Klaus

* Recognize Subject and Message-Id in embedded comments in HTML
  documents, in the form generated by MHonArc for mailing list
  archives (including lynx-dev).   Use these to generate a default
  Subject and an In-Reply-To header (currently not for VMS) when
  replying by mail (sending a 'C'omment, or following a mailto link)
  from such a page.  The old methods to get a title other than the
  fallback (the URL) still are there and have prcedence, by in reality
  seem to apply very rearely.  If no suitable comment strings are found
  or they are regarded as invalid (bad characters, not exactly right
  format) they are not used, and the fallback (URL as Subject, no
  In-Reply-To) applies.
* Use the Message-Id of a news article to generate a References header
  when posting a reply.  Lynx's new article listing doesn't understand
  threading, but this is nicer for other newsreader that do.  The
  References header of the referenced article is not used, so there will
  be only one message-id in the generated References header, but this
  is better than nothing.  The article's message-id is appended as a
  parameter to the URL of the generated newsreply link, in the form
  ";ref=...", so this extends the syntax of Lynx's newsreply: URL scheme.
  Nothing should have changed for snews: and other s-versions of the
  various URL schemes for news access.
* Message-Id and Subject of a news article are also made available for
  replying by mail.
* LYNews.c: Don't post a message that is empty or has only '>'-quoted text.
* HTNews.c: got rid of some suspicious fixed length buffers.  Fixed minor
  memory leaks.  Added abort of the target stream which was missing in
  some cases.  Create mailto: hrefs in URL-escaped form if necessary,
  they will be unescaped in LYMail.c.  (News URLs still don't use escaping
  the right way, especially for message-ids.)  Recognize special meaning
  of "Followup-to: poster" (don't treat "poster" as a newsgroup name).
  Other small tweaks.

--- lynx2-8-2.old/src/LYCharUtils.c     Mon Jan 18 06:29:20 1999
+++ lynx2-8-2/src/LYCharUtils.c Fri Feb  5 14:27:26 1999
@@ -3827,3 +3827,130 @@
     StrAllocCopy(*url, anchor->address);
     return TRUE;
 }
+
+/*
+**  This function is called from the SGML parser to look at comments
+**  and see whether we should collect some info from them.  Currently
+**  it only looks for comments with Message-Id and Subject info, in the
+**  exact form generated by MHonArc for archived mailing list.  If found,
+**  the info is stored in the document's HTParentAnchor.  It can later be
+**  used for generating a mail response.
+**
+**  We are extra picky here because there isn't any official definition
+**  for these kinds of comments - we might (and still can) misinterpret
+**  arbitrary comments as something they aren't.
+**
+**  If something doesn't look right, for example invalid characters, the
+**  strings are not stored.  Mail responses will use something else as
+**  the subject, probably the document URL, and will not have an
+**  In-Reply-To header.
+**
+**  All this is a hack - to do this the right way, mailing list archivers
+**  would have to agree on some better mechanism to make this kind of info
+**  from original mail headers available, for example using LINK.  - kw
+*/
+PUBLIC BOOLEAN LYCommentHacks ARGS2(
+       HTParentAnchor *,       anchor,
+       CONST char *,           comment)
+{
+    CONST char *cp = comment;
+    size_t len;
+
+    if (comment == NULL)
+       return FALSE;
+
+    if (!(anchor && anchor->address))
+       return FALSE;
+
+    if (strncmp(comment, "!--X-Message-Id: ", 17) == 0) {
+       char *messageid = NULL;
+       char *p;
+       for (cp = comment+17; *cp; cp++) {
+           if ((unsigned char)*cp >= 127 || !isgraph((unsigned char)*cp)) {
+               break;
+           }
+       }
+       if (strcmp(cp, " --")) {
+           return FALSE;
+       }
+       cp = comment + 17;
+       StrAllocCopy(messageid, cp);
+       /* This should be ok - message-id should only contain 7-bit ASCII */
+       if (!LYUCFullyTranslateString(&messageid, 0, 0, NO, NO, YES, st_URL))
+           return FALSE;
+       for (p = messageid; *p; p++) {
+           if ((unsigned char)*p >= 127 || !isgraph((unsigned char)*p)) {
+               break;
+           }
+       }
+       if (strcmp(p, " --")) {
+           FREE(messageid);
+           return FALSE;
+       }
+       if ((p = strchr(messageid, '@')) == NULL || p[1] == '\0') {
+           FREE(messageid);
+           return FALSE;
+       }
+       p = messageid;
+       if ((len = strlen(p)) >= 8 && !strcmp(&p[len-3], " --")) {
+           p[len-3] = '\0';
+       } else {
+           FREE(messageid);
+           return FALSE;
+       }
+       if (HTAnchor_setMessageID(anchor, messageid)) {
+           FREE(messageid);
+           return TRUE;
+       } else {
+           FREE(messageid);
+           return FALSE;
+       }
+    }
+    if (strncmp(comment, "!--X-Subject: ", 14) == 0) {
+       char *subject = NULL;
+       char *p;
+       for (cp = comment+14; *cp; cp++) {
+           if ((unsigned char)*cp >= 127 || !isprint((unsigned char)*cp)) {
+               return FALSE;
+           }
+       }
+       cp = comment + 14;
+       StrAllocCopy(subject, cp);
+       /* @@@
+        * This may not be the right thing for the subject - but mail
+        * subjects shouldn't contain 8-bit characters in raw form anyway.
+        * We have to unescape character entities, since that's what MHonArc
+        * seems to generate.  But if after that there are 8-bit characters
+        * the string is rejected.  We would probably not know correctly
+        * what charset to assume anyway - the mail sender's can differ from
+        * the archive's.  And the code for sending mail cannot deal well
+        * with 8-bit characters - we should not put them in the Subject
+        * header in raw form, but don't have MIME encoding implemented.
+        * Someone may want to do more about this...  - kw
+        */
+       if (!LYUCFullyTranslateString(&subject, 0, 0, NO, YES, NO, st_HTML))
+           return FALSE;
+       for (p = subject; *p; p++) {
+           if ((unsigned char)*p >= 127 || !isprint((unsigned char)*p)) {
+               FREE(subject);
+               return FALSE;
+           }
+       }
+       p = subject;
+       if ((len = strlen(p)) >= 4 && !strcmp(&p[len-3], " --")) {
+           p[len-3] = '\0';
+       } else {
+           FREE(subject);
+           return FALSE;
+       }
+       if (HTAnchor_setSubject(anchor, subject)) {
+           FREE(subject);
+           return TRUE;
+       } else {
+           FREE(subject);
+           return FALSE;
+       }
+    }
+
+    return FALSE;
+}
--- lynx2-8-2.old/src/GridText.h        Thu Jan 28 10:31:28 1999
+++ lynx2-8-2/src/GridText.h    Fri Feb  5 11:00:50 1999
@@ -125,6 +125,7 @@
 extern CONST char * HText_getOwner NOPARAMS;
 extern CONST char * HText_getContentBase NOPARAMS;
 extern CONST char * HText_getContentLocation NOPARAMS;
+extern CONST char * HText_getMessageID NOPARAMS;
 extern CONST char * HText_getRevTitle NOPARAMS;
 #ifdef USE_HASH
 extern CONST char * HText_getStyle NOPARAMS;
--- lynx2-8-2.old/src/GridText.c        Thu Jan 28 10:31:28 1999
+++ lynx2-8-2/src/GridText.c    Fri Feb  5 11:08:54 1999
@@ -5782,6 +5782,16 @@
           HTAnchor_content_location(HTMainText->node_anchor) : 0);
 }
 
+/*
+ *  HText_getMessageID returns the Message-ID of the
+ *  current document.
+ */
+PUBLIC CONST char * HText_getMessageID NOARGS
+{
+    return(HTMainText ?
+          HTAnchor_messageID(HTMainText->node_anchor) : NULL);
+}
+
 PUBLIC void HTuncache_current_document NOARGS
 {
     /*
--- lynx2-8-2.old/src/LYGetFile.c       Mon Jan 18 06:29:20 1999
+++ lynx2-8-2/src/LYGetFile.c   Fri Feb  5 11:20:08 1999
@@ -420,13 +420,24 @@
                    } else {
                        HTParentAnchor *tmpanchor;
                        CONST char *title;
+                       char *tmptitle = NULL;
 
                        title = "";
                        if ((tmpanchor = HTAnchor_parent(
                                                HTAnchor_findAddress(&WWWDoc)
-                                                       )) != NULL) {
-                           if (HTAnchor_title(tmpanchor)) {
+                                                       )) != NULL &&
+                           HTAnchor_title(tmpanchor)) {
                                title = HTAnchor_title(tmpanchor);
+                       } else if (HTMainAnchor && !LYUserSpecifiedURL) {
+                           title = HTAnchor_subject(HTMainAnchor);
+                           if (title && *title) {
+                               if (strncasecomp(title, "Re:", 3)) {
+                                   StrAllocCopy(tmptitle, "Re: ");
+                                   StrAllocCat(tmptitle, title);
+                                   title = tmptitle;
+                               }
+                           } else {
+                               title = "";
                            }
                        }
                        cp = (char *)strchr(doc->address,':')+1;
@@ -434,7 +445,10 @@
                                      ((HTMainAnchor && !LYUserSpecifiedURL) ?
                                       (char *)HTMainAnchor->address :
                                       (char *)doc->address),
-                                     title);
+                                     title,
+                                     (HTMainAnchor && !LYUserSpecifiedURL) ?
+                                      HTMainAnchor->message_id : NULL);
+                       FREE(tmptitle);
                    }
                    return(NULLFILE);
 
--- lynx2-8-2.old/src/LYMail.h  Fri Jul 24 22:01:02 1998
+++ lynx2-8-2/src/LYMail.h      Fri Jan  1 09:33:00 1999
@@ -21,6 +21,7 @@
 extern void reply_by_mail PARAMS((
        char *          mail_address,
        char *          filename,
-       CONST char *    title));
+       CONST char *    title,
+       CONST char *    refid));
 
 #endif /* LYMAIL_H */
--- lynx2-8-2.old/src/LYMail.c  Wed Jan 13 05:37:34 1999
+++ lynx2-8-2/src/LYMail.c      Fri Feb  5 11:39:44 1999
@@ -852,10 +852,11 @@
 **  reply_by_mail() invokes sendmail on Unix or mail on VMS to send
 **  a comment  from the users to the owner
 */
-PUBLIC void reply_by_mail ARGS3(
+PUBLIC void reply_by_mail ARGS4(
        char *,         mail_address,
        char *,         filename,
-       CONST char *,   title)
+       CONST char *,   title,
+       CONST char *,   refid)
 {
     char user_input[1000];
     FILE *fd, *fp;
@@ -886,11 +887,6 @@
     char hdrfile[LY_MAXPATH];
     FILE *hfd;
 
-    CTRACE(tfp, "reply_by_mail(\"%s\", \"%s\", \"%s\")\n",
-       mail_address?mail_address:"<nil>",
-       filename?filename:"<nil>",
-       title?title:"<nil>");
-
     if (!strncasecomp(system_mail, "PMDF SEND", 9)) {
        isPMDF = TRUE;
     }
@@ -900,6 +896,12 @@
     int n;
 #endif /* VMS */
 
+    CTRACE(tfp, "reply_by_mail(\"%s\", \"%s\", \"%s\", \"%s\")\n",
+       mail_address?mail_address:"<nil>",
+       filename?filename:"<nil>",
+       title?title:"<nil>",
+       refid?refid:"<nil>");
+
     term_letter = FALSE;
 
     if (mail_address && *mail_address) {
@@ -1264,6 +1266,12 @@
     StrAllocCat(header, "\n");
     sprintf(buf, "X-Mailer: Lynx, Version %s\n", LYNX_VERSION);
     StrAllocCat(header, buf);
+
+    if (refid && *refid) {
+       StrAllocCat(header, "In-Reply-To: <");
+       StrAllocCat(header, refid);
+       StrAllocCat(header, ">\n");
+    }
 #endif /* VMS */
 
     /*
--- lynx2-8-2.old/src/LYMainLoop.c      Thu Jan 28 10:31:28 1999
+++ lynx2-8-2/src/LYMainLoop.c  Fri Feb  5 12:19:50 1999
@@ -4025,17 +4025,31 @@
                         *  The owner_address is a mailto: URL.
                         */
                        CONST char *kp = HText_getRevTitle();
+                       CONST char *id = HText_getMessageID();
+                       char *tmptitle = NULL;
+                       if (!kp && HTMainAnchor) {
+                           kp = HTAnchor_subject(HTMainAnchor);
+                           if (kp && *kp) {
+                               if (strncasecomp(kp, "Re: ", 4)) {
+                                   StrAllocCopy(tmptitle, "Re: ");
+                                   StrAllocCat(tmptitle, kp);
+                                   kp = tmptitle;
+                               }
+                           }
+                       }
+
                        if (strchr(owner_address,':')!=NULL)
                             /*
                              *  Send a reply.  The address is after the colon.
                              */
                             reply_by_mail(strchr(owner_address,':')+1,
                                           curdoc.address,
-                                          (kp ? kp : ""));
+                                          (kp ? kp : ""), id);
                        else
                            reply_by_mail(owner_address, curdoc.address,
-                                         (kp ? kp : ""));
+                                         (kp ? kp : ""), id);
 
+                       FREE(tmptitle);
                        refresh_screen = TRUE;  /* to force a showpage */
                   }
               }
--- lynx2-8-2.old/src/LYNews.c  Wed Jan 13 05:37:34 1999
+++ lynx2-8-2/src/LYNews.c      Fri Feb  5 12:27:26 1999
@@ -25,6 +25,54 @@
 BOOLEAN term_message = FALSE;
 PRIVATE void terminate_message  PARAMS((int sig));
 
+PRIVATE BOOLEAN message_has_content ARGS1(
+    CONST char *,              filename)
+{
+    FILE *fp;
+    char buffer[72];
+    BOOLEAN in_headers = TRUE;
+
+    if (!filename || (fp = fopen(filename, "r")) == NULL) {
+       CTRACE(tfp, "Failed to open file %s for reading!\n",
+              filename ? filename : "(<null>)");
+       return FALSE;
+    }
+    while (fgets(buffer, sizeof(buffer), fp) != NULL) {
+       char *cp = buffer;
+       char firstnonblank = '\0';
+       if (*cp == '\0') {
+           break;
+       }
+       for (; *cp; cp++) {
+           if (*cp == '\n') {
+               break;
+           } else if (*cp != ' ') {
+               if (!firstnonblank && isgraph((unsigned char)*cp)) {
+                   firstnonblank = *cp;
+               }
+           }
+       }
+       if (*cp != '\n') {
+           int c;
+           while ((c = getc(fp)) != EOF && c != (int)(unsigned char)'\n') {
+               if (!firstnonblank && isgraph((unsigned char)c))
+                   firstnonblank = (char)c;
+           }
+       }
+       if (firstnonblank && firstnonblank != '>') {
+           if (!in_headers) {
+               fclose(fp);
+               return TRUE;
+           }
+       }
+       if (!firstnonblank) {
+           in_headers = FALSE;
+       }
+    }
+    fclose(fp);
+    return FALSE;
+}
+
 /*
 **  This function is called from HTLoadNews() to have the user
 **  create a file with news headers and a body for posting of
@@ -51,8 +99,10 @@
     char CJKfile[LY_MAXPATH];
     char *postfile = NULL;
     char *NewsGroups = NULL;
+    char *References = NULL;
     char *org = NULL;
     FILE *fp = NULL;
+    BOOLEAN nonempty = FALSE;
 
     /*
      *  Make sure a non-zero length newspost, newsreply,
@@ -90,7 +140,27 @@
      *  may also have been hex escaped. - FM
      */
     StrAllocCopy(NewsGroups, newsgroups);
+    if ((cp = strstr(NewsGroups, ";ref="))) {
+       *cp = '\0';
+       cp += 5;
+       if (*cp == '<') {
+           StrAllocCopy(References, cp);
+       } else {
+           StrAllocCopy(References, "<");
+           StrAllocCat(References, cp);
+           StrAllocCat(References, ">");
+       }
+       HTUnEscape(References);
+       if (!((cp = strchr(References, '@')) && cp > References + 1 &&
+             isalnum(cp[1]))) {
+           FREE(References);
+       }
+    }
     HTUnEscape(NewsGroups);
+    if (!*NewsGroups) {
+       LYCloseTempFP(fd);              /* Close the temp file. */
+       goto cleanup;
+    }  
 
     /*
      *  Allow ^C to cancel the posting,
@@ -192,6 +262,9 @@
     }
     fprintf(fd, "%s\n", user_input);
 
+    if (References) {
+       fprintf(fd, "References: %s\n", References);
+    }
     /*
      *  Add Newsgroups Summary and Keywords headers.
      */
@@ -245,6 +318,9 @@
        } else {
            start_curses();
        }
+
+       nonempty = message_has_content(my_tempfile);
+
     } else {
         /*
         *  Use the built in line editior.
@@ -266,6 +342,8 @@
        while (!STREQ(user_input,".") && !term_message) { 
            addch('\n');
            fprintf(fd,"%s\n",user_input);
+           if (!nonempty && strlen(user_input))
+               nonempty = TRUE;
            *user_input = '\0';
            if (LYgetstr(user_input, VISIBLE,
                         sizeof(user_input), NORECALL) < 0) {
@@ -280,6 +358,10 @@
        scrollok(stdscr, FALSE);        /* Stop scrolling.      */
     }
 
+    if (!nonempty) {
+       HTAlert(gettext("Message has no original text!"));
+       goto cleanup;
+    }
     /*
      *  Confirm whether to post, and if so,
      *  whether to append the sig file. - FM
@@ -371,6 +453,7 @@
        LYRemoveTemp(my_tempfile);
     LYRemoveTemp(CJKfile);
     FREE(NewsGroups);
+    FREE(References);
 
     return(postfile);
 }
--- lynx2-8-2.old/WWW/Library/Implementation/HTAnchor.c Thu Jan 28 10:31:28 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTAnchor.c     Fri Feb  5 12:35:38 1999
@@ -699,6 +699,8 @@
     FREE(me->content_disposition);
     FREE(me->content_location);
     FREE(me->content_md5);
+    FREE(me->message_id);
+    FREE(me->subject);
     FREE(me->date);
     FREE(me->expires);
     FREE(me->last_modified);
@@ -1060,6 +1062,44 @@
     return( me ? me->content_location : NULL);
 }
 
+/*     Message-ID, used for mail replies - kw
+*/
+PUBLIC CONST char * HTAnchor_messageID ARGS1(
+       HTParentAnchor *,       me)
+{
+    return( me ? me->message_id : NULL);
+}
+
+PUBLIC BOOL HTAnchor_setMessageID ARGS2(
+       HTParentAnchor *,       me,
+       CONST char *,           messageid)
+{
+    if (!(me && messageid && *messageid)) {
+       return FALSE;
+    }
+    StrAllocCopy(me->message_id, messageid);
+    return TRUE;
+}
+
+/*     Subject, used for mail replies - kw
+*/
+PUBLIC CONST char * HTAnchor_subject ARGS1(
+       HTParentAnchor *,       me)
+{
+    return( me ? me->subject : NULL);
+}
+
+PUBLIC BOOL HTAnchor_setSubject ARGS2(
+       HTParentAnchor *,       me,
+       CONST char *,           subject)
+{
+    if (!(me && subject && *subject)) {
+       return FALSE;
+    }
+    StrAllocCopy(me->subject, subject);
+    return TRUE;
+}
+
 /*     Link me Anchor to another given one
 **     -------------------------------------
 */
@@ -1203,7 +1243,7 @@
 **     text/plain
 **     from file:      HTFile.c ->  HTPlain.c               ->  GridText.c
 **
-**  The lock/set_by is used to lock e.g., a charset set by an explicit
+**  The lock/set_by is used to lock e.g. a charset set by an explicit
 **  HTTP MIME header against overriding by a HTML META tag - the MIME
 **  header has higher priority.  Defaults (from -assume_.. options etc.)
 **  will not override charset explicitly given by server.
--- lynx2-8-2.old/WWW/Library/Implementation/HTAnchor.h Sat Dec 12 22:10:36 1998
+++ lynx2-8-2/WWW/Library/Implementation/HTAnchor.h     Fri Feb  5 12:32:12 1999
@@ -118,6 +118,8 @@
   char *       content_disposition;    /* Content-Disposition */
   char *       content_location;       /* Content-Location */
   char *       content_md5;            /* Content-MD5 */
+  char *       message_id;             /* Message-ID */
+  char *       subject;                /* Subject */
   int          content_length;         /* Content-Length */
   char *       date;                   /* Date */
   char *       expires;                /* Expires */
@@ -357,6 +359,24 @@
 */
 extern CONST char * HTAnchor_content_location PARAMS((
        HTParentAnchor *        me));
+
+/*     Message-ID, used for mail replies - kw
+*/
+extern CONST char * HTAnchor_messageID PARAMS((
+       HTParentAnchor *        me));
+
+extern BOOL HTAnchor_setMessageID PARAMS((
+       HTParentAnchor *        me,
+       CONST char *            messageid));
+
+/*     Subject, used for mail replies - kw
+*/
+extern CONST char * HTAnchor_subject PARAMS((
+       HTParentAnchor *        me));
+
+extern BOOL HTAnchor_setSubject PARAMS((
+       HTParentAnchor *        me,
+       CONST char *            subject));
 
 /*     Link this Anchor to another given one
 **     -------------------------------------
--- lynx2-8-2.old/WWW/Library/Implementation/HTNews.c   Thu Dec 24 05:27:22 1998
+++ lynx2-8-2/WWW/Library/Implementation/HTNews.c       Fri Feb  5 13:14:28 1999
@@ -46,7 +46,6 @@
 #include <LYGlobalDefs.h>
 #include <LYLeaks.h>
 
-#define BIG 1024 /* @@@ */
 
 struct _HTStructured {
        CONST HTStructuredClass *       isa;
@@ -85,6 +84,9 @@
 PRIVATE int    diagnostic;                     /* level: 0=none 2=source */
 PRIVATE BOOL rawtext = NO;                     /* Flag: HEAD or -mime_headers 
*/
 PRIVATE HTList *NNTP_AuthInfo = NULL;          /* AUTHINFO database */
+PRIVATE char *name = NULL;
+PRIVATE char *address = NULL;
+PRIVATE char *dbuf = NULL;     /* dynamic buffer for long messages etc. */
 
 #define PUTC(c) (*targetClass.put_character)(target, c)
 #define PUTS(s) (*targetClass.put_string)(target, s)
@@ -113,6 +115,9 @@
     FREE(HTNewsHost);
     FREE(NewsHost);
     FREE(NewsHREF);
+    FREE(name);
+    FREE(address);
+    FREE(dbuf);
 }
 
 PRIVATE void free_NNTP_AuthInfo NOARGS
@@ -545,7 +550,6 @@
 */
 PRIVATE char * author_name ARGS1 (char *,email)
 {
-    static char *name = NULL;
     char *p, *e;
 
     StrAllocCopy(name, email);
@@ -582,7 +586,6 @@
 */
 PRIVATE char * author_address ARGS1(char *,email)
 {
-    static char *address = NULL;
     char *p, *at, *e;
 
     StrAllocCopy(address, email);
@@ -935,7 +938,8 @@
 **     s       Global socket number is OK
 **     HT      Global hypertext object is ready for appending text
 */
-PRIVATE int read_article NOARGS
+PRIVATE int read_article ARGS1(
+       HTParentAnchor *,       thisanchor)
 {
     char line[LINE_LENGTH+1];
     char *full_line = NULL;
@@ -949,6 +953,8 @@
     char *followupto = NULL;                   /* Followup list            */
     char *href = NULL;
     char *p = line;
+    char *cp;
+    CONST char *ccp;
     BOOL done = NO;
 
     /*
@@ -1009,6 +1015,9 @@
                        HTmmdecode(subject, subject);
                        HTrjis(subject, subject);
                    }
+                   if (*subject) {
+                       HTAnchor_setSubject(thisanchor, subject);
+                   }
 
                } else if (match(full_line, "DATE:")) {
                    StrAllocCopy(date, HTStrip(strchr(full_line,':')+1));
@@ -1044,6 +1053,14 @@
                } else if (match(full_line, "FOLLOWUP-TO:")) {
                    StrAllocCopy(followupto, HTStrip(strchr(full_line,':')+1));
 
+               } else if (match(full_line, "MESSAGE-ID:")) {
+                   char * msgid = HTStrip(full_line+11);
+                   if (msgid[0] == '<' && msgid[strlen(msgid)-1] == '>') {
+                       msgid[strlen(msgid)-1] = '\0';  /* Chop > */
+                       msgid++;                        /* Chop < */
+                       HTAnchor_setMessageID(thisanchor, msgid);
+                   }
+
                } /* end if match */
                p = line;                       /* Restart at beginning */
            } /* if end of line */
@@ -1064,9 +1081,15 @@
        */
        if (from || replyto) {
            char *temp=NULL;
-           StrAllocCopy(temp, replyto ? replyto : from);
+           StrAllocCopy(temp, author_address(replyto ? replyto : from));
            StrAllocCopy(href,"mailto:";);
-           StrAllocCat(href, author_address(temp));
+           if (strchr(temp, '%') || strchr(temp, '?')) {
+               cp = HTEscape(temp, URL_XPALPHAS);
+               StrAllocCat(href, cp);
+               FREE(cp);
+           } else {
+               StrAllocCat(href, temp);
+           }
            start_link(href, "made");
            PUTC('\n');
            FREE(temp);
@@ -1097,7 +1120,7 @@
            if (from)
                PUTS(from);
            else
-               PUTS(from);
+               PUTS(replyto);
            MAYBE_END(HTML_DT);
            PUTC('\n');
 
@@ -1146,6 +1169,59 @@
            FREE(organization);
        }
 
+       /* sanitize some headers - kw */
+       if (newsgroups &&
+           ((cp = strchr(newsgroups, '/')) ||
+            (cp = strchr(newsgroups, '(')))) {
+           *cp = '\0';
+       }
+       if (newsgroups && !*newsgroups) {
+           FREE(newsgroups);
+       }
+       if (followupto &&
+           ((cp = strchr(followupto, '/')) ||
+            (cp = strchr(followupto, '(')))) {
+           *cp = '\0';
+       }
+       if (followupto && !*followupto) {
+           FREE(followupto);
+       }
+
+       if (newsgroups && HTCanPost) {
+           START(HTML_DT);
+           START(HTML_B);
+           PUTS("Newsgroups:");
+           END(HTML_B);
+           PUTC('\n');
+           MAYBE_END(HTML_DT);
+           START(HTML_DD);
+           write_anchors(newsgroups);
+           MAYBE_END(HTML_DD);
+           PUTC('\n');
+       }
+
+       if (followupto && !strcasecmp(followupto, "poster")) {
+           /*
+           **  "Followup-To: poster" has special meaning.
+           **  Don't use it to construct a newsreply link. -kw
+           */
+           START(HTML_DT);
+           START(HTML_B);
+           PUTS("Followup to:");
+           END(HTML_B);
+           PUTC(' ');
+           if (href) {
+               start_anchor(href);
+               PUTS("poster");
+               END(HTML_A);
+           } else {
+               PUTS("poster");
+           }           
+           MAYBE_END(HTML_DT);
+           PUTC('\n');
+           FREE(followupto);
+       }
+
        if (newsgroups && HTCanPost) {
            /*
            **  We have permission to POST to this host,
@@ -1159,17 +1235,20 @@
            StrAllocCat(href, NewsHost);
            StrAllocCat(href, "/");
            StrAllocCat(href, (followupto ? followupto : newsgroups));
-
-           START(HTML_DT);
-           START(HTML_B);
-           PUTS("Newsgroups:");
-           END(HTML_B);
-           PUTC('\n');
-           MAYBE_END(HTML_DT);
-           START(HTML_DD);
-           write_anchors(newsgroups);
-           MAYBE_END(HTML_DD);
-           PUTC('\n');
+           if (*href == 'n' &&
+               (ccp = HTAnchor_messageID(thisanchor)) && *ccp) {
+               StrAllocCat(href, ";ref=");
+               if (strchr(ccp, '<') || strchr(ccp, '&') ||
+                   strchr(ccp, ' ') || strchr(ccp, ':') ||
+                   strchr(ccp, '/') || strchr(ccp, '%') ||
+                   strchr(ccp, ';')) {
+                   char *cp1 = HTEscape(ccp, URL_XPALPHAS);
+                   StrAllocCat(href, cp1);
+                   FREE(cp1);
+               } else {
+                   StrAllocCat(href, ccp);
+               }
+           }
 
            START(HTML_DT);
            START(HTML_B);
@@ -1177,7 +1256,11 @@
            END(HTML_B);
            PUTC(' ');
            start_anchor(href);
-           PUTS("newsgroup(s)");
+           if (strchr((followupto ? followupto : newsgroups), ',')) {
+               PUTS("newsgroups");
+           } else {
+               PUTS("newsgroup");
+           }
            END(HTML_A);
            MAYBE_END(HTML_DT);
            PUTC('\n');
@@ -1629,11 +1712,11 @@
            before = first;
        else
            before = first_required-HTNewsChunkSize;
-       sprintf(buffer, "%s%s/%d-%d", NewsHREF, groupName,
+       HTSprintf0(&dbuf, "%s%s/%d-%d", NewsHREF, groupName,
                                      before, first_required-1);
-       CTRACE(tfp, "    Block before is %s\n", buffer);
+       CTRACE(tfp, "    Block before is %s\n", dbuf);
        PUTC('(');
-       start_anchor(buffer);
+       start_anchor(dbuf);
        PUTS(gettext("Earlier articles"));
        END(HTML_A);
        PUTS("...)\n");
@@ -1908,13 +1991,13 @@
        int after;                      /* End of article after */
        after = last_required+HTNewsChunkSize;
        if (after == last)
-           sprintf(buffer, "%s%s", NewsHREF, groupName); /* original group */
+           HTSprintf0(&dbuf, "%s%s", NewsHREF, groupName); /* original group */
        else
-           sprintf(buffer, "%s%s/%d-%d", NewsHREF, groupName,
+           HTSprintf0(&dbuf, "%s%s/%d-%d", NewsHREF, groupName,
                                          last_required+1, after);
-       CTRACE(tfp, "    Block after is %s\n", buffer);
+       CTRACE(tfp, "    Block after is %s\n", dbuf);
        PUTC('(');
-       start_anchor(buffer);
+       start_anchor(dbuf);
        PUTS(gettext("Later articles"));
        END(HTML_A);
        PUTS("...)\n");
@@ -2352,13 +2435,16 @@
                return HT_NOT_LOADED;
            }
            if (status < 0) {
-               char message[256];
                NEWS_NETCLOSE(s);
                s = -1;
                CTRACE(tfp, "HTNews: Unable to connect to news host.\n");
                if (retries < 1)
                    continue;
-               sprintf(message, gettext("Could not access %s."), NewsHost);
+               if (!(post_wanted || reply_wanted ||
+                     spost_wanted || sreply_wanted)) {
+                   ABORT_TARGET;
+               }
+               HTSprintf0(&dbuf, gettext("Could not access %s."), NewsHost);
                FREE(NewsHost);
                FREE(NewsHREF);
                FREE(ProxyHost);
@@ -2368,7 +2454,7 @@
                    HTSYS_remove(postfile);
                    FREE(postfile);
                }
-               return HTLoadError(stream, 500, message);
+               return HTLoadError(stream, 500, dbuf);
            } else {
                CTRACE(tfp, "HTNews: Connected to news host %s.\n",
                            NewsHost);
@@ -2379,7 +2465,6 @@
                                status);
                }
                if (((status = response(NULL)) / 100) != 2) {
-                       char message[BIG];
                        NEWS_NETCLOSE(s);
                        s = -1;
                        if (status == HT_INTERRUPTED) {
@@ -2401,10 +2486,14 @@
                        }
                        if (retries < 1)
                            continue;
-                       sprintf(message,
+                       if (!(post_wanted || reply_wanted ||
+                             spost_wanted || sreply_wanted)) {
+                           ABORT_TARGET;
+                       }
+                       HTSprintf0(&dbuf,
                                gettext("Can't read news info.  News host %.20s 
responded: %.200s"),
                                NewsHost, response_text);
-                       return HTLoadError(stream, 500, message);
+                       return HTLoadError(stream, 500, dbuf);
                }
                if (status == 200) {
                    HTCanPost = TRUE;
@@ -2627,7 +2716,7 @@
            **  Get an article from a news group. - FM
            */
            _HTProgress(gettext("Reading news article."));
-           status = read_article();
+           status = read_article(anAnchor);
        }
        if (status == HT_INTERRUPTED) {
            _HTProgress(CONNECTION_INTERRUPTED);
--- lynx2-8-2.old/WWW/Library/Implementation/SGML.c     Mon Jan 18 06:29:20 1999
+++ lynx2-8-2/WWW/Library/Implementation/SGML.c Fri Feb  5 13:37:36 1999
@@ -504,6 +504,8 @@
        strncmp(s, "!--#", 4) == 0 &&
        LYCheckForCSI(context->node_anchor, (char **)&context->url) == TRUE) {
        LYDoCSI(context->url, s, (char **)&context->csi);
+    } else {
+       LYCommentHacks(context->node_anchor, context->string->data);
     }
 
     return;
--- lynx2-8-2.old/WWW/Library/Implementation/SGML.h     Wed Dec 16 15:56:42 1998
+++ lynx2-8-2/WWW/Library/Implementation/SGML.h Fri Feb  5 13:27:12 1999
@@ -229,6 +229,7 @@
   */
 extern BOOLEAN LYCheckForCSI PARAMS((HTParentAnchor *anchor, char **url));
 extern void LYDoCSI PARAMS((char *url, CONST char *comment, char **csi));
+extern BOOLEAN LYCommentHacks PARAMS((HTParentAnchor *anchor, CONST char 
*comment));
 
 /*
 

reply via email to

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