int output_length = 0;
char new_window[SIZ];
int brak = 0;
- int in_link = 0;
+ int alevel = 0;
int i;
int linklen;
"?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)) {
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 */
- else if ( (in_link == 0)
+ /* 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) && (alevel == 0)
&& (!strncasecmp(ptr, "http://", 7))) {
linklen = 0;
/* Find the end of the link */
||(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;
}
else {
/*
- * We need to know when we're inside a pair of <A>...</A>
- * tags, so we don't turn things that look like URL's into
- * links, when they're already links.
+ * We need to know when we're inside a tag,
+ * so we don't turn things that look like URL's into
+ * links, when they're already links - or image sources.
*/
- if (!strncasecmp(ptr, "<A ", 3)) {
- ++in_link;
- }
- if (!strncasecmp(ptr, "</A", 3)) {
- --in_link;
- }
if (*ptr == '<') ++brak;
if (*ptr == '>') --brak;
+ if (!strncasecmp(ptr, "</A>", 3)) --alevel;
converted_msg[output_length] = *ptr++;
converted_msg[++output_length] = 0;
}
}
/* Output our big pile of markup */
- write(WC->http_sock, converted_msg, output_length);
+ client_write(converted_msg, output_length);
/* A little trailing vertical whitespace... */
wprintf("<BR><BR>\n");