* Fixed some garbled output resulting from turning things that look like
authorArt Cancro <ajc@citadel.org>
Sat, 12 Jun 2004 04:26:38 +0000 (04:26 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 12 Jun 2004 04:26:38 +0000 (04:26 +0000)
  links into links.

webcit/ChangeLog
webcit/html2html.c

index c39d098c9538b2d5cb5d7e63c895da8c596a8f35..57ffb2f4b745862a73dff904eb8929a057e7e7ea 100644 (file)
@@ -1,4 +1,8 @@
 $Log$
+Revision 521.5  2004/06/12 04:26:38  ajc
+* Fixed some garbled output resulting from turning things that look like
+  links into links.
+
 Revision 521.4  2004/06/11 16:09:36  ajc
 * Moved the room graphic to the left of the room name in the banner, to
   make it more consistent with the rest of the site.
@@ -1889,4 +1893,3 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
-
index fdab14556feeb0dba4f808114ea061d1bbf7fa45..6eb490a602faf891c2a2fbb1fa5584da65157768 100644 (file)
@@ -44,6 +44,7 @@ void output_html(void) {
        int output_length = 0;
        char new_window[SIZ];
        int brak = 0;
+       int alevel = 0;
        int i;
        int linklen;
 
@@ -124,7 +125,7 @@ void output_html(void) {
                                "?force_room=_MAIL_&recp=");
                        output_length += 47;
                        ptr = &ptr[16];
-                       ++brak;
+                       ++alevel;
                }
                /* Make links open in a separate window */
                else if (!strncasecmp(ptr, "<A HREF=", 8)) {
@@ -133,12 +134,12 @@ void output_html(void) {
                        sprintf(&converted_msg[output_length], new_window);
                        output_length += strlen(new_window);
                        ptr = &ptr[8];
-                       ++brak;
+                       ++alevel;
                }
                /* Turn anything that looks like a URL into a real link, as long
                 * as it's not inside a tag already
                 */
-               else if ( (brak == 0)
+               else if ( (brak == 0) && (alevel == 0)
                     && (!strncasecmp(ptr, "http://", 7))) {
                                linklen = 0;
                                /* Find the end of the link */
@@ -147,8 +148,11 @@ void output_html(void) {
                                           ||(isspace(ptr[i]))
                                           ||(ptr[i]==10)
                                           ||(ptr[i]==13)
+                                          ||(ptr[i]=='(')
                                           ||(ptr[i]==')')
+                                          ||(ptr[i]=='<')
                                           ||(ptr[i]=='>')
+                                          ||(ptr[i]=='[')
                                           ||(ptr[i]==']')
                                        ) linklen = i;
                                        if (linklen > 0) break;
@@ -182,6 +186,7 @@ void output_html(void) {
                         */
                        if (*ptr == '<') ++brak;
                        if (*ptr == '>') --brak;
+                       if (!strncasecmp(ptr, "</A>", 3)) --alevel;
                        converted_msg[output_length] = *ptr++;
                        converted_msg[++output_length] = 0;
                }