]> 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 ddd1c32fc32f27199509fe447f924a719807aac6..5db43b33fef068982cbf951c5d129ee5517cb4c6 100644 (file)
@@ -1,9 +1,7 @@
 /*
- * $Id$
- *
  * Server-side module for Wiki rooms.  This handles things like version control. 
  * 
- * Copyright (c) 2009 by the citadel.org team
+ * Copyright (c) 2009-2011 by the citadel.org team
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -53,7 +51,6 @@
 #include "config.h"
 #include "control.h"
 #include "user_ops.h"
-#include "policy.h"
 #include "database.h"
 #include "msgbase.h"
 #include "euidindex.h"
@@ -425,7 +422,7 @@ void wiki_rev_callback(char *name, char *filename, char *partnum, char *disp,
        CtdlLogPrintf(CTDL_DEBUG, "callback found rev: %s\n", this_rev);
 
        /* Perform the patch */
-       fp = popen("patch -f -s -p0 --global-reject-file=/dev/null >/dev/null 2>/dev/null", "w");
+       fp = popen("patch -f -s -p0 -/dev/null >/dev/null 2>/dev/null", "w");
        if (fp) {
                /* Replace the filenames in the patch with the tempfilename we're actually tweaking */
                fprintf(fp, "--- %s\n", hecbd->tempfilename);
@@ -575,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);
                }
@@ -586,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));