]> code.citadel.org Git - citadel.git/commitdiff
* serv_ical.c: Verify that objects posted to My Calendar> are of type
authorMichael Hampton <io_error@uncensored.citadel.org>
Sat, 3 Feb 2001 10:02:12 +0000 (10:02 +0000)
committerMichael Hampton <io_error@uncensored.citadel.org>
Sat, 3 Feb 2001 10:02:12 +0000 (10:02 +0000)
  text/x-calendar or text/calendar; abort saving if not

citadel/ChangeLog
citadel/serv_ical.c

index c2330ad9be2ec151c4cc4deb70dd841028ab91df..b281961be9eaf438b520e25eb817f68a9845d1bb 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 573.80  2001/02/03 10:02:12  error
+ * serv_ical.c: Verify that objects posted to My Calendar> are of type
+   text/x-calendar or text/calendar; abort saving if not
+
  Revision 573.79  2001/02/03 09:30:46  error
  * serv_ical.c: now creates a My Calendar> personal room, sets attributes
 
@@ -2361,3 +2365,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
+
index 267da1c731ae0b7fbe961c0861122996b13c4995..8d4d5d58fbf1180011272cfed73fd209e546f1fc 100644 (file)
@@ -7,11 +7,15 @@
  *
  */
 
+#include "sysdep.h"
 #include <unistd.h>
 #include <sys/types.h>
 #include <limits.h>
 #include <stdio.h>
-#include "sysdep.h"
+#include <string.h>
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
 #include "serv_ical.h"
 #include "citadel.h"
 #include "server.h"
@@ -33,12 +37,12 @@ void cmd_ical(char *argbuf)
                return;
        }
 
-       cprintf("%d I (will) support|ICAL,ITIP\n", OK);
+       cprintf("%d I support|ICAL\n", OK);
        return;
 }
 
 
-/* We can't know if the calendar room exists so we just create it at login */
+/* We don't know if the calendar room exists so we just create it at login */
 void ical_create_room(void)
 {
        char roomname[ROOMNAMELEN];
@@ -68,7 +72,46 @@ int ical_obj_beforeread(struct CtdlMessage *msg)
 /* See if we need to prevent the object from being saved */
 int ical_obj_beforesave(struct CtdlMessage *msg)
 {
-       return 0;
+       char roomname[ROOMNAMELEN];
+       char *p;
+       int a;
+       
+       /*
+        * Only messages with content-type text/calendar or text/x-calendar
+        * may be saved to My Calendar>.  If the message is bound for
+        * My Calendar> but doesn't have this content-type, throw an error
+        * so that the message may not be posted.
+        */
+
+       /* First determine if this is our room */
+       MailboxName(roomname, &CC->usersupp, USERCALENDARROOM);
+       if (strncmp(roomname, msg->cm_fields['O'], ROOMNAMELEN))
+               return 0;       /* It's not us... */
+
+       /* Then determine content-type of the message */
+       
+       /* It must be an RFC822 message! */
+       /* FIXME: Not handling MIME multipart messages; implement with IMIP */
+       if (msg->cm_format_type != 4)
+               return 1;       /* You tried to save a non-RFC822 message! */
+       
+       /* Find the Content-Type: header */
+       p = msg->cm_fields['M'];
+       a = strlen(p);
+       while (--a > 0) {
+               if (!strncasecmp(p, "Content-Type: ", 14)) {    /* Found it */
+                       if (!strncasecmp(p + 14, "text/x-calendar", 15) ||
+                           !strncasecmp(p + 14, "text/calendar", 13))
+                               return 0;
+                       else
+                               return 1;
+               }
+               p++;
+       }
+       
+       /* Oops!  No Content-Type in this message!  How'd that happen? */
+       lprintf(7, "RFC822 message with no Content-Type header!\n");
+       return 1;
 }