]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
* lets start knit-picking on buffersizes.
[citadel.git] / webcit / messages.c
index bff4ec081677f140824163fd0699533db75b999c..032b79c04b9337d238cbeb9391a2364a1a64268b 100644 (file)
@@ -493,6 +493,7 @@ void display_parsed_vcard(struct vCard *v, int full) {
        
                        else if (!strcasecmp(firsttoken, "email")) {
                                if (!IsEmptyStr(mailto)) strcat(mailto, "<br />");
+                               long len;
                                strcat(mailto,
                                        "<a href=\"display_enter"
                                        "?force_room=_MAIL_?recp=");
@@ -503,7 +504,8 @@ void display_parsed_vcard(struct vCard *v, int full) {
                                urlesc(&mailto[strlen(mailto)], ">");
 
                                strcat(mailto, "\">");
-                               stresc(&mailto[strlen(mailto)], thisvalue, 1, 1);
+                               len = strlen(mailto);
+                               stresc(mailto+len, SIZ - len, thisvalue, 1, 1);
                                strcat(mailto, "</A>");
                        }
                        else if (!strcasecmp(firsttoken, "tel")) {
@@ -1093,11 +1095,12 @@ void read_message(long msgnum, int printable_view, char *section) {
        /** Boring old 80-column fixed format text gets handled this way... */
        else if ( (!strcasecmp(mime_content_type, "text/plain"))
                || (!strcasecmp(mime_content_type, "text")) ) {
+               buf [0] = '\0';
                while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
                        int len;
                        len = strlen(buf);
-                       if (buf[len-1] == '\n') buf[--len] = 0;
-                       if (buf[len-1] == '\r') buf[--len] = 0;
+                       if ((len > 0) && buf[len-1] == '\n') buf[--len] = 0;
+                       if ((len > 0) && buf[len-1] == '\r') buf[--len] = 0;
 
 #ifdef HAVE_ICONV
                        if (ic != (iconv_t)(-1) ) {
@@ -1835,8 +1838,8 @@ int abcmp(const void *ab1, const void *ab2) {
  * \param tabbuf the tabbuffer to add name to
  * \param name the name to add to the tabbuffer
  */
-void nametab(char *tabbuf, char *name) {
-       stresc(tabbuf, name, 0, 0);
+void nametab(char *tabbuf, long len, char *name) {
+       stresc(tabbuf, len, name, 0, 0);
        tabbuf[0] = toupper(tabbuf[0]);
        tabbuf[1] = tolower(tabbuf[1]);
        tabbuf[2] = tolower(tabbuf[2]);
@@ -1888,8 +1891,8 @@ void do_addrbook_view(struct addrbookent *addrbook, int num_ab) {
                tabfirst = i * NAMESPERPAGE;
                tablast = tabfirst + NAMESPERPAGE - 1;
                if (tablast > (num_ab - 1)) tablast = (num_ab - 1);
-               nametab(tabfirst_label, addrbook[tabfirst].ab_name);
-               nametab(tablast_label, addrbook[tablast].ab_name);
+               nametab(tabfirst_label, 64, addrbook[tabfirst].ab_name);
+               nametab(tablast_label, 64, addrbook[tablast].ab_name);
                sprintf(this_tablabel, "%s&nbsp;-&nbsp;%s", tabfirst_label, tablast_label);
                tablabels[i] = strdup(this_tablabel);
        }
@@ -2468,7 +2471,7 @@ void readloop(char *oper)
         */
        if (is_bbview) {
                /** begin bbview scroller */
-               wprintf("<form name=\"msgomatic\" class=\"selector_top\" >");
+               wprintf("<form name=\"msgomatictop\" class=\"selector_top\" >");
                wprintf(_("Reading #"), lowest_displayed, highest_displayed);
 
                wprintf("<select name=\"whichones\" size=\"1\" "
@@ -2524,24 +2527,23 @@ void readloop(char *oper)
                wprintf(_("of %d messages."), nummsgs);
 
                /** forward/reverse */
-               wprintf("&nbsp;<select name=\"direction\" size=\"1\" "
-                       "OnChange=\"location.href=msgomatictop.direction.options"
-                       "[selectedIndex].value\">\n"
-               );
-
-               wprintf("<option %s value=\"%s?sortby=forward\">",
-                       (bbs_reverse ? "" : "selected"),
+               wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
+                       "OnChange=\"location.href='%s?sortby=forward'\"",  
+                       (bbs_reverse ? "" : "checked"),
                        oper
                );
+               wprintf(">");
                wprintf(_("oldest to newest"));
-               wprintf("</option>\n");
-       
-               wprintf("<option %s value=\"%s?sortby=reverse\">",
-                       (bbs_reverse ? "selected" : ""),
+               wprintf("&nbsp;&nbsp;&nbsp;&nbsp;");
+
+               wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
+                       "OnChange=\"location.href='%s?sortby=reverse'\"", 
+                       (bbs_reverse ? "checked" : ""),
                        oper
                );
+               wprintf(">");
                wprintf(_("newest to oldest"));
-               wprintf("</option>\n");
+               wprintf("\n");
        
                wprintf("</select></form>\n");
                /** end bbview scroller */
@@ -2692,26 +2694,24 @@ void readloop(char *oper)
                wprintf(_("of %d messages."), nummsgs);
 
                /** forward/reverse */
-               wprintf("&nbsp;<select name=\"direction\" size=\"1\" "
-                       "OnChange=\"location.href=msgomatic.direction.options"
-                       "[selectedIndex].value\">\n"
-               );
-
-               wprintf("<option %s value=\"%s?sortby=forward\">",
-                       (bbs_reverse ? "" : "selected"),
+               wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
+                       "OnChange=\"location.href='%s?sortby=forward'\"",  
+                       (bbs_reverse ? "" : "checked"),
                        oper
                );
+               wprintf(">");
                wprintf(_("oldest to newest"));
-               wprintf("</option>\n");
-       
-               wprintf("<option %s value=\"%s?sortby=reverse\">",
-                       (bbs_reverse ? "selected" : ""),
+               wprintf("&nbsp;&nbsp;&nbsp;&nbsp;");
+               wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
+                       "OnChange=\"location.href='%s?sortby=reverse'\"", 
+                       (bbs_reverse ? "checked" : ""),
                        oper
                );
+               wprintf(">");
                wprintf(_("newest to oldest"));
-               wprintf("</option>\n");
-       
-               wprintf("</select></form>\n");
+               wprintf("\n");
+
+               wprintf("</form>\n");
                /** end bbview scroller */
        }
 
@@ -3289,7 +3289,7 @@ void display_enter(void)
        do_template("richedit");
 
        /** Enumerate any attachments which are already in place... */
-       wprintf("<div><img src=\"static/diskette_24x.gif\" class=\"imgedit\" ");
+       wprintf("<div class=\"attachment buttons\"><img src=\"static/diskette_24x.gif\" class=\"imgedit\" > ");
        wprintf(_("Attachments:"));
        wprintf(" ");
        wprintf("<select name=\"which_attachment\" size=1>");
@@ -3306,7 +3306,7 @@ void display_enter(void)
        /** Now offer the ability to attach additional files... */
        wprintf("&nbsp;&nbsp;&nbsp;");
        wprintf(_("Attach file:"));
-       wprintf(" <input name=\"attachfile\" "
+       wprintf(" <input name=\"attachfile\" class=\"attachfile\" "
                "size=16 type=\"file\">\n&nbsp;&nbsp;"
                "<input type=\"submit\" name=\"attach_button\" value=\"%s\">\n", _("Add"));
        wprintf("</div>");
@@ -3389,12 +3389,12 @@ void confirm_move_msg(void)
 
        output_headers(1, 1, 2, 0, 0, 0);
        wprintf("<div id=\"banner\">\n");
-       wprintf("<TABLE WIDTH=100%% BORDER=0><TR><TD>");
-       wprintf("<SPAN CLASS=\"titlebar\">");
+       wprintf("<h1>");
        wprintf(_("Confirm move of message"));
-       wprintf("</SPAN>\n");
-       wprintf("</TD></TR></TABLE>\n");
-       wprintf("</div>\n<div id=\"content\">\n");
+       wprintf("</h1>");
+       wprintf("</div>\n");
+
+       wprintf("<div id=\"content\" class=\"service\">\n");
 
        wprintf("<CENTER>");