+ ++brak;
+ if ( ((strchr(ptr, ':') < strchr(ptr, '/')))
+ && ((strchr(ptr, '/') < strchr(ptr, '>')))
+ ) {
+ /* open external links to new window */
+ StrBufAppendPrintf(converted_msg, new_window);
+ ptr = &ptr[8];
+ }
+ else if ( (treat_as_wiki) && (strncasecmp(ptr, "<a href=\"wiki?", 14)) ) {
+ content_length += 64;
+ StrBufAppendPrintf(converted_msg, "<a href=\"wiki?page=");
+ ptr = &ptr[9];
+ }
+ else {
+ StrBufAppendPrintf(converted_msg, "<a href=\"");
+ ptr = &ptr[9];
+ }
+ }
+ /** Fixup <img src="cid:... ...> to fetch the mime part */
+ else if (!strncasecmp(ptr, "<img ", 5)) {
+ char* tag_end=strchr(ptr,'>');
+ char* src=strstr(ptr, " src=\"cid:");
+ char *cid_start, *cid_end;
+ ++brak;
+
+ if (src &&
+ (cid_start=strchr(src,':')) &&
+ (cid_end=strchr(cid_start,'"')) &&
+ (cid_end < tag_end)) {
+
+ /* copy tag and attributes up to src="cid: */
+ StrBufAppendBufPlain(converted_msg, ptr, src - ptr, 0);
+ cid_start++;
+
+ /* add in /webcit/mimepart/<msgno>/CID/
+ trailing / stops dumb URL filters getting excited */
+ StrBufAppendPrintf(converted_msg,
+ "src=\"/webcit/mimepart/%d/",msgnum);
+ StrBufAppendBufPlain(converted_msg, cid_start, cid_end - cid_start, 0);
+ StrBufAppendBufPlain(converted_msg, "/\"", -1, 0);
+
+ ptr = cid_end+1;
+ }
+ StrBufAppendBufPlain(converted_msg, ptr, tag_end - ptr, 0);
+ ptr = tag_end;