]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/wiki/serv_wiki.c
Ugly hack to fix wiki history broken by the 'message xxx is not in this room' securit...
[citadel.git] / citadel / modules / wiki / serv_wiki.c
index 8f306a5dd70d7be96c0e985cad0888ce8308e628..5db43b33fef068982cbf951c5d129ee5517cb4c6 100644 (file)
@@ -572,7 +572,7 @@ void wiki_rev(char *pagename, char *rev, char *operation)
                        fseek(fp, 0L, SEEK_SET);
                        msg->cm_fields['M'] = malloc(len + 1);
                        rv = fread(msg->cm_fields['M'], len, 1, fp);
-                       CtdlLogPrintf(CTDL_DEBUG, "did %d blocks of %d bytes\n", rv, len);
+                       CtdlLogPrintf(CTDL_DEBUG, "did %d blocks of %ld bytes\n", rv, len);
                        msg->cm_fields['M'][len] = 0;
                        fclose(fp);
                }
@@ -583,6 +583,18 @@ void wiki_rev(char *pagename, char *rev, char *operation)
                        msg->cm_fields['A'] = strdup("Citadel");
                        CtdlCreateRoom(wwm, 5, "", 0, 1, 1, VIEW_BBS);  /* Not an error if already exists */
                        msgnum = CtdlSubmitMsg(msg, NULL, wwm, 0);      /* Store the revision here */
+
+                       /*
+                        * WARNING: VILE SLEAZY HACK
+                        * This will avoid the 'message xxx is not in this room' security error,
+                        * but only if the client fetches the message we just generated immediately
+                        * without first trying to perform other fetch operations.
+                        */
+                       if (CC->cached_msglist != NULL) free(CC->cached_msglist);
+                       CC->cached_num_msgs = 1;
+                       CC->cached_msglist = malloc(sizeof(long));
+                       CC->cached_msglist[0] = msgnum;
+
                }
                else if (!strcasecmp(operation, "revert")) {
                        snprintf(timestamp, sizeof timestamp, "%ld", time(NULL));