]> code.citadel.org Git - citadel.git/blobdiff - webcit/html2html.c
html2html.c: when converting links, don't add quotes to URL's
[citadel.git] / webcit / html2html.c
index 1f2d358c93b75987e4aa06d49136621fa0af2227..ca8804c1aa6d707699863bbf91785d12c9ad984e 100644 (file)
@@ -103,15 +103,20 @@ void output_html(char *supplied_charset, int treat_as_wiki) {
        while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
                line_length = strlen(buf);
                buffer_length = content_length + line_length + 2;
-               msg = realloc(msg, buffer_length);
-               if (msg == NULL) {
+               ptr = realloc(msg, buffer_length);
+               if (ptr == NULL) {
                        wprintf("<b>");
                        wprintf(_("realloc() error! couldn't get %d bytes: %s"),
                                buffer_length + 1,
                                strerror(errno));
                        wprintf("</b><br /><br />\n");
+                       while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+                               /** flush */
+                       }
+                       free(msg);
                        return;
                }
+               msg = ptr;
                strcpy(&msg[content_length], buf);
                content_length += line_length;
                strcpy(&msg[content_length], "\n");
@@ -216,7 +221,7 @@ void output_html(char *supplied_charset, int treat_as_wiki) {
           && (strcasecmp(charset, ""))
        ) {
                lprintf(9, "Converting %s to UTF-8\n", charset);
-               ic = iconv_open("UTF-8", charset);
+               ic = ctdl_iconv_open("UTF-8", charset);
                if (ic == (iconv_t)(-1) ) {
                        lprintf(5, "%s:%d iconv_open() failed: %s\n",
                                __FILE__, __LINE__, strerror(errno));
@@ -269,7 +274,7 @@ void output_html(char *supplied_charset, int treat_as_wiki) {
                        ++alevel;
                }
                /** Make external links open in a separate window */
-               else if (!strncasecmp(ptr, "<a href=", 8)) {
+               else if (!strncasecmp(ptr, "<a href=\"", 9)) {
                        ++alevel;
                        if ( ((strchr(ptr, ':') < strchr(ptr, '/')))
                             &&  ((strchr(ptr, '/') < strchr(ptr, '>'))) 
@@ -289,9 +294,9 @@ void output_html(char *supplied_charset, int treat_as_wiki) {
                                ptr = &ptr[9];
                        }
                        else {
-                               sprintf(&converted_msg[output_length], "<a href=");
-                               output_length += 8;
-                               ptr = &ptr[8];
+                               sprintf(&converted_msg[output_length], "<a href=\"");
+                               output_length += 9;
+                               ptr = &ptr[9];
                        }
                }
                /**