]> code.citadel.org Git - citadel.git/commitdiff
* Encode GroupDAV uid's using more concise string escaping, because the
authorArt Cancro <ajc@citadel.org>
Wed, 2 Feb 2005 23:25:22 +0000 (23:25 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 2 Feb 2005 23:25:22 +0000 (23:25 +0000)
  old way was making KOrganizer choke.

webcit/ChangeLog
webcit/groupdav.h
webcit/groupdav_get.c
webcit/groupdav_main.c
webcit/groupdav_propfind.c
webcit/groupdav_put.c

index b053846d1b98c2d0c31e963861c92a6facae3175..813fe9d30b22961d87d8e3d1254209f3db77b73a 100644 (file)
@@ -1,4 +1,8 @@
 $Log$
+Revision 528.36  2005/02/02 23:25:21  ajc
+* Encode GroupDAV uid's using more concise string escaping, because the
+  old way was making KOrganizer choke.
+
 Revision 528.35  2005/02/02 04:13:36  ajc
 * Debugged the GroupDAV service with KOrganizer.  It's mostly working now.
 
@@ -2290,4 +2294,3 @@ 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 bbc035a55906c5657e888b9f72ff61fe1b806213..fa2ae002e8d47a417ebe1104e6fb8a9c85152d00 100644 (file)
@@ -8,3 +8,6 @@ void groupdav_delete(char *, char *);
 void groupdav_propfind(char *);
 long locate_message_by_uid(char *);
 void groupdav_folder_list(void);
+void euid_escapize(char *, char *);
+void euid_unescapize(char *, char *);
+
index 9e6edc51445dfa5f85ea70f554082b062e19748d..23fee5608c208ba1bb12c38606f8671fd8d20134 100644 (file)
@@ -69,9 +69,11 @@ void groupdav_get(char *dav_pathname) {
        }
 
        dav_msgnum = locate_message_by_uid(dav_uid);
+       lprintf(9, "* That maps to msgnum %ld\n", dav_msgnum);
        serv_printf("MSG2 %ld", dav_msgnum);
        serv_gets(buf);
        if (buf[0] != '1') {
+               lprintf(9, "* and it was not found.\n");
                wprintf("HTTP/1.1 404 not found\n");
                groupdav_common_headers();
                wprintf(
@@ -84,6 +86,7 @@ void groupdav_get(char *dav_pathname) {
                return;
        }
 
+       lprintf(9, "* and it was retrieved successfully.\n");
        wprintf("HTTP/1.1 200 OK\n");
        groupdav_common_headers();
        wprintf("ETag: \"%ld\"\n", dav_msgnum);
index 28efe121d58d7bf3a4348ee90076ca9e298aa1e2..6e57b4652931c817fa699b6e3abfdc1c7a24438d 100644 (file)
@@ -38,6 +38,58 @@ void groupdav_common_headers(void) {
 }
 
 
+
+/*
+ * string conversion function
+ */
+void euid_escapize(char *target, char *source) {
+       int i;
+       int target_length = 0;
+
+       strcpy(target, "");
+       for (i=0; i<strlen(source); ++i) {
+               if (isalnum(source[i])) {
+                       target[target_length] = source[i];
+                       target[++target_length] = 0;
+               }
+               else {
+                       sprintf(&target[target_length], "_%02X", source[i]);
+                       target_length += 3;
+               }
+       }
+}
+
+/*
+ * string conversion function
+ */
+void euid_unescapize(char *target, char *source) {
+       int a, b;
+       char hex[3];
+       int target_length = 0;
+
+       strcpy(target, "");
+
+       for (a = 0; a < strlen(source); ++a) {
+               if (source[a] == '_') {
+                       hex[0] = source[a + 1];
+                       hex[1] = source[a + 2];
+                       hex[2] = 0;
+                       b = 0;
+                       sscanf(hex, "%02x", &b);
+                       target[target_length] = b;
+                       target[++target_length] = 0;
+                       a += 2;
+               }
+               else {
+                       target[target_length] = source[a];
+                       target[++target_length] = 0;
+               }
+       }
+}
+
+
+
+
 /*
  * Main entry point for GroupDAV requests
  */
index 3cf03da5284015745af59613cc6dcbf9f38a9f93..ca7502617a953fd8faf66a4a33ce8a5585050229 100644 (file)
@@ -42,14 +42,7 @@ long locate_message_by_uid(char *uid) {
        long retval = (-1L);
 
        /* Decode the uid */
-       j=0;
-       for (i=0; i<strlen(uid); i=i+2) {
-               ch = 0;
-               sscanf(&uid[i], "%02x", &ch);
-               decoded_uid[j] = ch;
-               decoded_uid[j+1] = 0;
-               ++j;
-       }
+       euid_unescapize(decoded_uid, uid);
 
        serv_puts("MSGS ALL|0|1");
        serv_gets(buf);
@@ -149,6 +142,7 @@ void groupdav_propfind(char *dav_pathname) {
        char msgnum[SIZ];
        char buf[SIZ];
        char uid[SIZ];
+       char encoded_uid[SIZ];
        long *msgs = NULL;
        int num_msgs = 0;
        int i, j;
@@ -230,10 +224,8 @@ void groupdav_propfind(char *dav_pathname) {
                        }
                        wprintf("/groupdav/");
                        urlescputs(WC->wc_roomname);
-                       wprintf("/");
-                       for (j=0; j<strlen(uid); ++j) {
-                               wprintf("%02X", uid[j]);
-                       }
+                       euid_escapize(encoded_uid, uid);
+                       wprintf("/%s", encoded_uid);
                        wprintf("</D:href>\n");
                        wprintf("   <D:propstat>\n");
                        wprintf("    <D:status>HTTP/1.1 200 OK</D:status>\n");
index 45729c7bf3874b487d9e52a4766330fe29c1f551..f3041ab228a97a18cd4bb3211fd71b311b0690a5 100644 (file)
@@ -98,6 +98,7 @@ void groupdav_put(char *dav_pathname, char *dav_ifmatch,
         * version, so we fail...
         */
        if (strlen(dav_ifmatch) > 0) {
+               lprintf(9, "* ifmatch failed, bailing out\n");
                old_msgnum = locate_message_by_uid(dav_uid);
                if (atol(dav_ifmatch) != old_msgnum) {
                        wprintf("HTTP/1.1 412 Precondition Failed\n");
@@ -112,6 +113,12 @@ void groupdav_put(char *dav_pathname, char *dav_ifmatch,
         * which allows a confirmation to be sent back to us.  That's how we
         * extract the message ID.
         */
+       lprintf(9, "* I am %s/%s/%s\n",
+               WC->wc_username,
+               WC->wc_password,
+               WC->wc_roomname
+       );
+       lprintf(9, "* allowing upload (old_msgnum=%ld, ifmatch=%s)\n", old_msgnum, dav_ifmatch);
        serv_puts("ENT0 1|||4|||1|");
        serv_gets(buf);
        if (buf[0] != '8') {
@@ -145,6 +152,7 @@ void groupdav_put(char *dav_pathname, char *dav_ifmatch,
        }
 
        /* Tell the client what happened. */
+       lprintf(9, "* new_msgnum = %ld\n", new_msgnum);
 
        /* Citadel failed in some way? */
        if (new_msgnum < 0L) {
@@ -160,6 +168,7 @@ void groupdav_put(char *dav_pathname, char *dav_ifmatch,
 
        /* We created this item for the first time. */
        if (old_msgnum < 0L) {
+               lprintf(9, "* new item created\n");
                wprintf("HTTP/1.1 201 Created\n");
                groupdav_common_headers();
                wprintf("Content-Length: 0\n");
@@ -177,6 +186,7 @@ void groupdav_put(char *dav_pathname, char *dav_ifmatch,
        }
 
        /* We modified an existing item. */
+       lprintf(9, "* existing item replaced\n");
        wprintf("HTTP/1.1 204 No Content\n");
        groupdav_common_headers();
        wprintf("Content-Length: 0\n\n");