$Log$
+Revision 500.9 2003/07/06 22:06:59 ajc
+* When converting "anything that looks like a URL" to a real link, first
+ make sure that it isn't already inside a link. This fixes most of the
+ long, ugly URL strings sent by eBay.
+* Automatically dismantle mailto: links in HTML messages, and convert
+ them to WebCit mail links (clicking on it sends the user to the Mail
+ room and begins composing a new message with the recipient and subject
+ fields pre-populated).
+
Revision 500.8 2003/06/29 20:51:21 ajc
* Worked around a rendering bug in Satan's Browser that was causing it
to draw the calendar month view much wider than the actual screen wdith
1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
* webserver.c: warning fix
+
int output_length = 0;
char new_window[SIZ];
int brak = 0;
+ int in_link = 0;
int i;
int linklen;
strcpy(converted_msg, "");
ptr = msgstart;
while (ptr < msgend) {
+ /* Change mailto: links to WebCit mail, by replacing the
+ * link with one that points back to our mail room. Due to
+ * the way we parse URL's, it'll even handle mailto: links
+ * that have "?subject=" in them.
+ */
+ if (!strncasecmp(ptr, "<A HREF=\"mailto:", 16)) {
+ content_length += 64;
+ converted_msg = realloc(converted_msg, content_length);
+ sprintf(&converted_msg[output_length],
+ "<A HREF=\"/display_enter"
+ "?force_room=_MAIL_&recp=");
+ output_length += 47;
+ ptr = &ptr[16];
+ ++brak;
+ }
/* Make links open in a separate window */
- if (!strncasecmp(ptr, "<A HREF=", 8)) {
+ else if (!strncasecmp(ptr, "<A HREF=", 8)) {
content_length += 64;
converted_msg = realloc(converted_msg, content_length);
sprintf(&converted_msg[output_length], new_window);
ptr = &ptr[8];
++brak;
}
- /* Turn loose URL's into hot links */
- else if ( (brak == 0)
+ /* Turn anything that looks like a URL into a real link */
+ else if ( (in_link == 0)
&& (!strncasecmp(ptr, "http://", 7))) {
linklen = 0;
/* Find the end of the link */
}
}
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.
+ */
+ if (!strncasecmp(ptr, "<A ", 3)) {
+ ++in_link;
+ }
+ if (!strncasecmp(ptr, "</A", 3)) {
+ --in_link;
+ }
if (*ptr == '<') ++brak;
if (*ptr == '>') --brak;
converted_msg[output_length] = *ptr++;