]> code.citadel.org Git - citadel.git/commitdiff
* html.c: allow parsing of tags even when they're qualified (i.e. <TAG foo=bar>
authorArt Cancro <ajc@citadel.org>
Thu, 3 Jun 2004 02:49:14 +0000 (02:49 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 3 Jun 2004 02:49:14 +0000 (02:49 +0000)
          instead of just <TAG> )
* html.c: handle escaped decimal characters (such as &#39; for an apostrophe)

citadel/ChangeLog
citadel/html.c

index 3da56a84a6c92bf18b1b43f032a4dda48436cfab..a7a49fe05b083d5300a375aac21185f89e8c4073 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 621.6  2004/06/03 02:49:14  ajc
+ * html.c: allow parsing of tags even when they're qualified (i.e. <TAG foo=bar>
+           instead of just <TAG> )
+ * html.c: handle escaped decimal characters (such as &#39; for an apostrophe)
+
  Revision 621.5  2004/06/03 02:28:16  ajc
  * citadel_ipc.c: SETR command was missing defaultview and flags2.  Added.
 
@@ -5807,3 +5812,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index 4b910252859367a9c4f43bf647261d1ad6e713dc..9663fc9b968a2b044cec0ac525c7c92b67167a9b 100644 (file)
@@ -61,7 +61,7 @@ char *html_to_ascii(char *inputmsg, int screenwidth, int do_citaformat) {
        char *outptr;
        size_t outptr_buffer_size;
        size_t output_len = 0;
-       int i, j, ch, did_out, rb;
+       int i, j, ch, did_out, rb, scanch;
        int nest = 0;           /* Bracket nesting level */
 
        inptr = inputmsg;
@@ -116,8 +116,13 @@ char *html_to_ascii(char *inputmsg, int screenwidth, int do_citaformat) {
                                strcpy(tag, "");
                        }
 
-                       else if (ch == '>') {
+                       else if (ch == '>') {   /* We have a tag. */
                                if (nest > 0) --nest;
+
+                               /* Unqualify the tag (truncate at first space) */
+                               if (strchr(tag, ' ') != NULL) {
+                                       strcpy(strchr(tag, ' '), "");
+                               }
                                
                                if (!strcasecmp(tag, "P")) {
                                        strcat(outbuf, "\n\n");
@@ -234,6 +239,24 @@ char *html_to_ascii(char *inputmsg, int screenwidth, int do_citaformat) {
                                strcpy(&outbuf[i+3], &outbuf[i+5]);
                        }
 
+                       /* two-digit decimal equivalents */
+                       else if ((!strncmp(&outbuf[i], "&#", 2))
+                             && (outbuf[i+4] == ';') ) {
+                               scanch = 0;
+                               sscanf(&outbuf[i+2], "%02d", &scanch);
+                               outbuf[i] = scanch;
+                               strcpy(&outbuf[i+1], &outbuf[i+5]);
+                       }
+
+                       /* three-digit decimal equivalents */
+                       else if ((!strncmp(&outbuf[i], "&#", 2))
+                             && (outbuf[i+5] == ';') ) {
+                               scanch = 0;
+                               sscanf(&outbuf[i+2], "%03d", &scanch);
+                               outbuf[i] = scanch;
+                               strcpy(&outbuf[i+1], &outbuf[i+6]);
+                       }
+
                }
 
                /* Make sure the output buffer is big enough */