* When converting "anything that looks like a URL" to a real link, first
authorArt Cancro <ajc@citadel.org>
Sun, 6 Jul 2003 22:07:00 +0000 (22:07 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 6 Jul 2003 22:07:00 +0000 (22:07 +0000)
  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).

webcit/ChangeLog
webcit/html2html.c
webcit/messages.c
webcit/webcit.c
webcit/webcit.h

index fee11c4de84e58305e2dae1eb0f14c7c650ed561..15afc68728713bbbcd9c2e9703e4b8668fc4cca5 100644 (file)
@@ -1,4 +1,13 @@
 $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
@@ -1518,3 +1527,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index 023ab7c4af8184dfc9193003d28079a8d3964f38..3b6a9c3e83ad57fb7419d01a42572d20c3b22ace 100644 (file)
@@ -44,6 +44,7 @@ void output_html(void) {
        int output_length = 0;
        char new_window[SIZ];
        int brak = 0;
+       int in_link = 0;
        int i;
        int linklen;
 
@@ -111,8 +112,23 @@ void output_html(void) {
        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);
@@ -120,8 +136,8 @@ void output_html(void) {
                        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 */
@@ -158,6 +174,17 @@ void output_html(void) {
                                }
                }
                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++;
index 5988a9599d87ceb348b89311e8e9dc6f7073a3dc..67ee5a07f8ffefcb8cae22d794ae3602460d642b 100644 (file)
@@ -1131,8 +1131,11 @@ void display_enter(void)
        long now;
        struct wc_attachment *att;
 
-       output_headers(1);
+       if (strlen(bstr("force_room")) > 0) {
+               gotoroom(bstr("force_room"), 0);
+       }
 
+       output_headers(1);
        sprintf(buf, "ENT0 0|%s|0|0", bstr("recp"));
        serv_puts(buf);
        serv_gets(buf);
index b5b9e18ce302bf6af09d79e32407c6539572ca8e..90984f330d96044447f86cba787d24dd48a064bb 100644 (file)
@@ -92,11 +92,11 @@ void addurls(char *url)
                for (a = 0; a <= b; ++a)
                        ++up;
 
-               /* locate the & sign */
+               /* locate "&" and "?" delimiters */
                ptr = up;
                b = strlen(up);
                for (a = 0; a < strlen(up); ++a) {
-                       if (!strncmp(ptr, "&", 1)) {
+                       if ( (ptr[0] == '&') || (ptr[0] == '?') ) {
                                b = a;
                                break;
                        }
index e722af7cf3685b66d34f388bf434aeb8a59688f6..af858845cb6e429584bce71610614470b6ecb80c 100644 (file)
@@ -409,6 +409,7 @@ void ical_dezonify(icalcomponent *cal);
 void partstat_as_string(char *buf, icalproperty *attendee);
 icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp);
 void check_attendee_availability(icalcomponent *supplied_vevent);
+void do_freebusy(char *req);
 #endif
 
 extern char *months[];