Do not attempt to search for database records of length 0.
authorArt Cancro <ajc@citadel.org>
Tue, 7 Sep 2021 18:41:56 +0000 (18:41 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 7 Sep 2021 18:41:56 +0000 (18:41 +0000)
13 files changed:
citadel/database.c
citadel/euidindex.c
citadel/internet_addressing.c
citadel/modules/ctdlproto/serv_messages.c
citadel/modules/wiki/serv_wiki.c
citadel/msgbase.c
citadel/room_ops.c
citadel/user_ops.c
libcitadel/lib/libcitadel.h
webcit/dav_propfind.c
webcit/roomops.c
webcit/sitemap.c
webcit/wiki.c

index dfeb4f013946cb1c4f9c1cda84f2a8143c7b192a..37a9d79745f59ec0902951d757f2ab2e41cb17c5 100644 (file)
@@ -32,7 +32,6 @@
 #include <stdio.h>
 #include <dirent.h>
 #include <zlib.h>
-
 #include <db.h>
 
 #if DB_VERSION_MAJOR < 5
@@ -548,6 +547,13 @@ static DBC *localcursor(int cdb) {
  * using the cdb_free() routine.
  */
 struct cdbdata *cdb_fetch(int cdb, const void *key, int keylen) {
+
+       syslog(LOG_DEBUG, "\x1b[35mdatabase: fetch from db %d a key of length %d\x1b[0m", cdb, keylen);
+
+       if (keylen == 0) {
+               abort();
+       }
+
        struct cdbdata *tempcdb;
        DBT dkey, dret;
        int ret;
@@ -559,8 +565,9 @@ struct cdbdata *cdb_fetch(int cdb, const void *key, int keylen) {
        if (TSD->tid != NULL) {
                memset(&dret, 0, sizeof(DBT));
                dret.flags = DB_DBT_MALLOC;
-               ret = dbp[cdb]->get(dbp[cdb], TSD->tid, &dkey, &dret, 0);               // crashing here
-       } else {
+               ret = dbp[cdb]->get(dbp[cdb], TSD->tid, &dkey, &dret, 0);
+       }
+       else {
                DBC *curs;
 
                do {
@@ -588,7 +595,8 @@ struct cdbdata *cdb_fetch(int cdb, const void *key, int keylen) {
                syslog(LOG_ERR, "db: cdb_fetch: Cannot allocate memory for tempcdb");
                cdb_abort();
                return NULL;    /* make it easier for static analysis... */
-       } else {
+       }
+       else {
                tempcdb->len = dret.size;
                tempcdb->ptr = dret.data;
                cdb_decompress_if_necessary(tempcdb);
index 247a998a83d86cf99ba35371555322cb74c458e1..6d87c19a8253bcc59abce09f77ef27d2e720326d 100644 (file)
@@ -48,7 +48,6 @@ int DoesThisRoomNeedEuidIndexing(struct ctdlroom *qrbuf) {
                case VIEW_TASKS:        return(1);
                case VIEW_NOTES:        return(1);
                case VIEW_WIKI:         return(1);
-               case VIEW_WIKIMD:       return(1);
                case VIEW_BLOG:         return(1);
        }
        
index abbd376aef718a8c5c15cdf8f78f7de1ee1487c1..db9e776ad27b17933b6f86c86aafa7ea37987a63 100644 (file)
@@ -313,8 +313,7 @@ int CtdlHostAlias(char *fqdn) {
 /*
  * Determine whether a given Internet address belongs to the current user
  */
-int CtdlIsMe(char *addr, int addr_buf_len)
-{
+int CtdlIsMe(char *addr, int addr_buf_len) {
        struct recptypes *recp;
        int i;
 
@@ -400,6 +399,8 @@ int expand_aliases(char *name) {
        char node[64];
        char *t;
 
+       syslog(LOG_DEBUG, "internet_addressing: \x1b[34mexpand_aliases(%s)\x1b[0m", name);
+
        char *aliases = CtdlGetSysConfig(GLOBAL_ALIASES);       // First hit the Global Alias Table
        if (aliases) {
                char *aptr = aliases;
@@ -535,6 +536,8 @@ struct recptypes *validate_recipients(char *supplied_recipients, const char *Rem
        char *org_recp;
        char this_recp[256];
 
+       syslog(LOG_DEBUG, "internet_addressing: \x1b[32mvalidate_recipients(%s) \x1b[0m", supplied_recipients);
+
        ret = (struct recptypes *) malloc(sizeof(struct recptypes));                    // Initialize
        if (ret == NULL) return(NULL);
        memset(ret, 0, sizeof(struct recptypes));                                       // set all values to null/zero
index 022ce2b7ee47bc5b9601f112a5e5c6fb46a7f7c2..af88c67cfa413fec60cbf2d4165fde2ffed60e3e 100644 (file)
@@ -1,20 +1,17 @@
-/*
- * represent messages to the citadel clients
- *
- * Copyright (c) 1987-2020 by the citadel.org team
- *
- * This program is open source software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
+// Message-related protocol commands for Citadel clients
+//
+// Copyright (c) 1987-2021 by the citadel.org team
+//
+// This program is open source software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 3.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 
 #include <stdio.h>
 #include <libcitadel.h>
-
 #include "citserver.h"
 #include "ctdl_module.h"
 #include "internet_addressing.h"
 extern char *msgkeys[];
 
 
-/*
- * Back end for the MSGS command: output message number only.
- */
-void simple_listing(long msgnum, void *userdata)
-{
+// Back end for the MSGS command: output message number only.
+void simple_listing(long msgnum, void *userdata) {
        cprintf("%ld\n", msgnum);
 }
 
 
-/*
- * Back end for the MSGS command: output header summary.
- */
-void headers_listing(long msgnum, void *userdata)
-{
+// Back end for the MSGS command: output header summary.
+void headers_listing(long msgnum, void *userdata) {
        struct CtdlMessage *msg;
        int output_mode =  *(int *)userdata;
 
@@ -96,14 +87,14 @@ void headers_listing(long msgnum, void *userdata)
        CM_Free(msg);
 }
 
-typedef struct _msg_filter{
+typedef struct _msg_filter {
        HashList *Filter;
        HashPos *p;
        StrBuf *buffer;
-}msg_filter;
+} msg_filter;
 
-void headers_brief_filter(long msgnum, void *userdata)
-{
+
+void headers_brief_filter(long msgnum, void *userdata) {
        long i, l;
        struct CtdlMessage *msg;
        msg_filter *flt = (msg_filter*) userdata;
@@ -134,11 +125,8 @@ void headers_brief_filter(long msgnum, void *userdata)
        cputbuf(flt->buffer);
 }
 
-/*
- * Back end for the MSGS command: output EUID header.
- */
-void headers_euid(long msgnum, void *userdata)
-{
+// Back end for the MSGS command: output EUID header.
+void headers_euid(long msgnum, void *userdata) {
        struct CtdlMessage *msg;
 
        msg = CtdlFetchMessage(msgnum, 0);
@@ -155,13 +143,9 @@ void headers_euid(long msgnum, void *userdata)
 }
 
 
-
-/*
- * cmd_msgs()  -  get list of message #'s in this room
- *             implements the MSGS server command using CtdlForEachMessage()
- */
-void cmd_msgs(char *cmdbuf)
-{
+// cmd_msgs()  -  get list of message #'s in this room
+//             implements the MSGS server command using CtdlForEachMessage()
+void cmd_msgs(char *cmdbuf) {
        int mode = 0;
        char which[16];
        char buf[256];
@@ -298,6 +282,7 @@ void cmd_msgs(char *cmdbuf)
        cprintf("000\n");
 }
 
+
 /*
  * display a message (mode 0 - Citadel proprietary)
  */
@@ -314,11 +299,8 @@ void cmd_msg0(char *cmdbuf)
 }
 
 
-/*
- * display a message (mode 2 - RFC822)
- */
-void cmd_msg2(char *cmdbuf)
-{
+// display a message (mode 2 - RFC822)
+void cmd_msg2(char *cmdbuf) {
        long msgid;
        int headers_only = HEADERS_ALL;
 
@@ -329,11 +311,8 @@ void cmd_msg2(char *cmdbuf)
 }
 
 
-/* 
- * Display a message using MIME content types
- */
-void cmd_msg4(char *cmdbuf)
-{
+// Display a message using MIME content types
+void cmd_msg4(char *cmdbuf) {
        long msgid;
        char section[64];
 
@@ -343,11 +322,8 @@ void cmd_msg4(char *cmdbuf)
 }
 
 
-/* 
- * Client tells us its preferred message format(s)
- */
-void cmd_msgp(char *cmdbuf)
-{
+// Client tells us its preferred message format(s)
+void cmd_msgp(char *cmdbuf) {
        if (!strcasecmp(cmdbuf, "dont_decode")) {
                CC->msg4_dont_decode = 1;
                cprintf("%d MSG4 will not pre-decode messages.\n", CIT_OK);
@@ -359,11 +335,8 @@ void cmd_msgp(char *cmdbuf)
 }
 
 
-/*
- * Open a component of a MIME message as a download file 
- */
-void cmd_opna(char *cmdbuf)
-{
+// Open a component of a MIME message as a download file 
+void cmd_opna(char *cmdbuf) {
        long msgid;
        char desired_section[128];
 
@@ -375,11 +348,8 @@ void cmd_opna(char *cmdbuf)
 }                      
 
 
-/*
- * Open a component of a MIME message and transmit it all at once
- */
-void cmd_dlat(char *cmdbuf)
-{
+// Open a component of a MIME message and transmit it all at once
+void cmd_dlat(char *cmdbuf) {
        long msgid;
        char desired_section[128];
 
@@ -390,12 +360,9 @@ void cmd_dlat(char *cmdbuf)
        CtdlOutputMsg(msgid, MT_SPEW_SECTION, 0, 1, 1, NULL, 0, NULL, NULL, NULL);
 }
 
-/*
- * message entry  -  mode 0 (normal)
- */
-void cmd_ent0(char *entargs)
-{
-       struct CitContext *CCC = CC;
+
+// message entry  -  mode 0 (normal)
+void cmd_ent0(char *entargs) {
        int post = 0;
        char recp[SIZ];
        char cc[SIZ];
@@ -437,7 +404,6 @@ void cmd_ent0(char *entargs)
        switch(CC->room.QRdefaultview) {
        case VIEW_NOTES:
        case VIEW_WIKI:
-       case VIEW_WIKIMD:
                extract_token(supplied_euid, entargs, 9, '|', sizeof supplied_euid);
                break;
        default:
@@ -458,9 +424,8 @@ void cmd_ent0(char *entargs)
                NULL,
                POST_LOGGED_IN,
                (!IsEmptyStr(references))               /* is this a reply?  or a top-level post? */
-               );
-       if (err)
-       {
+       );
+       if (err) {
                cprintf("%d %s\n", err, errmsg);
                return;
        }
@@ -468,32 +433,31 @@ void cmd_ent0(char *entargs)
        /* Check some other permission type things. */
 
        if (IsEmptyStr(newusername)) {
-               strcpy(newusername, CCC->user.fullname);
+               strcpy(newusername, CC->user.fullname);
        }
-       if (  (CCC->user.axlevel < AxAideU)
-             && (strcasecmp(newusername, CCC->user.fullname))
-             && (strcasecmp(newusername, CCC->cs_inet_fn))
-               ) {     
+       if (  (CC->user.axlevel < AxAideU)
+             && (strcasecmp(newusername, CC->user.fullname))
+             && (strcasecmp(newusername, CC->cs_inet_fn))
+       ) {     
                cprintf("%d You don't have permission to author messages as '%s'.\n",
                        ERROR + HIGHER_ACCESS_REQUIRED,
                        newusername
-                       );
+               );
                return;
        }
 
-
        if (IsEmptyStr(newuseremail)) {
                newuseremail_ok = 1;
        }
 
        if (!IsEmptyStr(newuseremail)) {
-               if (!strcasecmp(newuseremail, CCC->cs_inet_email)) {
+               if (!strcasecmp(newuseremail, CC->cs_inet_email)) {
                        newuseremail_ok = 1;
                }
-               else if (!IsEmptyStr(CCC->cs_inet_other_emails)) {
-                       j = num_tokens(CCC->cs_inet_other_emails, '|');
+               else if (!IsEmptyStr(CC->cs_inet_other_emails)) {
+                       j = num_tokens(CC->cs_inet_other_emails, '|');
                        for (i=0; i<j; ++i) {
-                               extract_token(buf, CCC->cs_inet_other_emails, i, '|', sizeof buf);
+                               extract_token(buf, CC->cs_inet_other_emails, i, '|', sizeof buf);
                                if (!strcasecmp(newuseremail, buf)) {
                                        newuseremail_ok = 1;
                                }
@@ -509,32 +473,35 @@ void cmd_ent0(char *entargs)
                return;
        }
 
-       CCC->cs_flags |= CS_POSTING;
+       CC->cs_flags |= CS_POSTING;
 
-       /* In mailbox rooms we have to behave a little differently --
-        * make sure the user has specified at least one recipient.  Then
-        * validate the recipient(s).  We do this for the Mail> room, as
-        * well as any room which has the "Mailbox" view set - unless it
-        * is the DRAFTS room which does not require recipients
-        */
+       // In mailbox rooms we have to behave a little differently --
+       // make sure the user has specified at least one recipient.  Then
+       // validate the recipient(s).  We do this for the Mail> room, as
+       // well as any room which has the "Mailbox" view set - unless it
+       // is the DRAFTS room which does not require recipients.
 
-       if ( (  ( (CCC->room.QRflags & QR_MAILBOX) && (!strcasecmp(&CCC->room.QRname[11], MAILROOM)) )
-               || ( (CCC->room.QRflags & QR_MAILBOX) && (CCC->curr_view == VIEW_MAILBOX) )
-                    ) && (strcasecmp(&CCC->room.QRname[11], USERDRAFTROOM)) !=0 ) {
-               if (CCC->user.axlevel < AxProbU) {
+       if ( (  ( (CC->room.QRflags & QR_MAILBOX) && (!strcasecmp(&CC->room.QRname[11], MAILROOM)) )
+               || ( (CC->room.QRflags & QR_MAILBOX) && (CC->curr_view == VIEW_MAILBOX) )
+                    ) && (strcasecmp(&CC->room.QRname[11], USERDRAFTROOM)) !=0 ) {
+               if (CC->user.axlevel < AxProbU) {
                        strcpy(recp, "sysop");
                        strcpy(cc, "");
                        strcpy(bcc, "");
                }
 
+               TRACE;
                valid_to = validate_recipients(recp, NULL, 0);
+               TRACE;
                if (valid_to->num_error > 0) {
                        cprintf("%d %s\n", ERROR + NO_SUCH_USER, valid_to->errormsg);
                        free_recipients(valid_to);
                        return;
                }
 
+               TRACE;
                valid_cc = validate_recipients(cc, NULL, 0);
+               TRACE;
                if (valid_cc->num_error > 0) {
                        cprintf("%d %s\n", ERROR + NO_SUCH_USER, valid_cc->errormsg);
                        free_recipients(valid_to);
@@ -542,7 +509,9 @@ void cmd_ent0(char *entargs)
                        return;
                }
 
+               TRACE;
                valid_bcc = validate_recipients(bcc, NULL, 0);
+               TRACE;
                if (valid_bcc->num_error > 0) {
                        cprintf("%d %s\n", ERROR + NO_SUCH_USER, valid_bcc->errormsg);
                        free_recipients(valid_to);
@@ -561,7 +530,7 @@ void cmd_ent0(char *entargs)
                }
 
                if (valid_to->num_internet + valid_cc->num_internet + valid_bcc->num_internet > 0) {
-                       if (CtdlCheckInternetMailPermission(&CCC->user)==0) {
+                       if (CtdlCheckInternetMailPermission(&CC->user)==0) {
                                cprintf("%d You do not have permission "
                                        "to send Internet mail.\n",
                                        ERROR + HIGHER_ACCESS_REQUIRED);
@@ -573,7 +542,7 @@ void cmd_ent0(char *entargs)
                }
 
                if ( ( (valid_to->num_internet + valid_to->num_ignet + valid_cc->num_internet + valid_cc->num_ignet + valid_bcc->num_internet + valid_bcc->num_ignet) > 0)
-                    && (CCC->user.axlevel < AxNetU) ) {
+                    && (CC->user.axlevel < AxNetU) ) {
                        cprintf("%d Higher access required for network mail.\n",
                                ERROR + HIGHER_ACCESS_REQUIRED);
                        free_recipients(valid_to);
@@ -584,8 +553,8 @@ void cmd_ent0(char *entargs)
        
                if ((RESTRICT_INTERNET == 1)
                    && (valid_to->num_internet + valid_cc->num_internet + valid_bcc->num_internet > 0)
-                   && ((CCC->user.flags & US_INTERNET) == 0)
-                   && (!CCC->internal_pgm)) {
+                   && ((CC->user.flags & US_INTERNET) == 0)
+                   && (!CC->internal_pgm)) {
                        cprintf("%d You don't have access to Internet mail.\n",
                                ERROR + HIGHER_ACCESS_REQUIRED);
                        free_recipients(valid_to);
@@ -598,16 +567,16 @@ void cmd_ent0(char *entargs)
 
        /* Is this a room which has anonymous-only or anonymous-option? */
        anonymous = MES_NORMAL;
-       if (CCC->room.QRflags & QR_ANONONLY) {
+       if (CC->room.QRflags & QR_ANONONLY) {
                anonymous = MES_ANONONLY;
        }
-       if (CCC->room.QRflags & QR_ANONOPT) {
+       if (CC->room.QRflags & QR_ANONOPT) {
                if (anon_flag == 1) {   /* only if the user requested it */
                        anonymous = MES_ANONOPT;
                }
        }
 
-       if ((CCC->room.QRflags & QR_MAILBOX) == 0) {
+       if ((CC->room.QRflags & QR_MAILBOX) == 0) {
                recp[0] = 0;
        }
 
@@ -615,7 +584,7 @@ void cmd_ent0(char *entargs)
         * strongly recommended in this room, if either the SUBJECTREQ flag
         * is set, or if there is one or more Internet email recipients.
         */
-       if (CCC->room.QRflags2 & QR2_SUBJECTREQ) subject_required = 1;
+       if (CC->room.QRflags2 & QR2_SUBJECTREQ) subject_required = 1;
        if ((valid_to)  && (valid_to->num_internet > 0))        subject_required = 1;
        if ((valid_cc)  && (valid_cc->num_internet > 0))        subject_required = 1;
        if ((valid_bcc) && (valid_bcc->num_internet > 0))       subject_required = 1;
@@ -645,8 +614,8 @@ void cmd_ent0(char *entargs)
                cprintf("%d send message\n", SEND_LISTING);
        }
 
-       msg = CtdlMakeMessage(&CCC->user, recp, cc,
-                             CCC->room.QRname, anonymous, format_type,
+       msg = CtdlMakeMessage(&CC->user, recp, cc,
+                             CC->room.QRname, anonymous, format_type,
                              newusername, newuseremail, subject,
                              ((!IsEmptyStr(supplied_euid)) ? supplied_euid : NULL),
                              NULL, references);
@@ -669,7 +638,9 @@ void cmd_ent0(char *entargs)
                strcat(all_recps, bcc);
        }
        if (!IsEmptyStr(all_recps)) {
+               TRACE;
                valid = validate_recipients(all_recps, NULL, 0);
+               TRACE;
        }
        else {
                valid = NULL;
@@ -690,8 +661,8 @@ void cmd_ent0(char *entargs)
                if (do_confirm) {
                        cprintf("%ld\n", msgnum);
 
-                       if (StrLength(CCC->StatusMessage) > 0) {
-                               cprintf("%s\n", ChrPtr(CCC->StatusMessage));
+                       if (StrLength(CC->StatusMessage) > 0) {
+                               cprintf("%s\n", ChrPtr(CC->StatusMessage));
                        }
                        else if (msgnum >= 0L) {
                                client_write(HKEY("Message accepted.\n"));
@@ -716,11 +687,9 @@ void cmd_ent0(char *entargs)
        return;
 }
 
-/*
- * Delete message from current room
- */
-void cmd_dele(char *args)
-{
+
+// Delete message from current room
+void cmd_dele(char *args) {
        int num_deleted;
        int i;
        char msgset[SIZ];
@@ -762,12 +731,8 @@ void cmd_dele(char *args)
 }
 
 
-
-/*
- * move or copy a message to another room
- */
-void cmd_move(char *args)
-{
+// move or copy a message to another room
+void cmd_move(char *args) {
        char msgset[SIZ];
        char msgtok[32];
        long *msgs;
index 3917237aa36b3bb5f67c4e7bcab7fb652b60a9d7..ebbb3292554c9141dee3b608dad3aabce2c6f384 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Server-side module for Wiki rooms.  This handles things like version control. 
  * 
- * Copyright (c) 2009-2020 by the citadel.org team
+ * Copyright (c) 2009-2021 by the citadel.org team
  *
  * This program is open source software.  You can redistribute it and/or
  * modify it under the terms of the GNU General Public License, version 3.
@@ -60,7 +60,6 @@ char *wwm = "9999999999.WikiWaybackMachine";
  * This involves fetching the old version of the page if it exists.
  */
 int wiki_upload_beforesave(struct CtdlMessage *msg, struct recptypes *recp) {
-       struct CitContext *CCC = CC;
        long old_msgnum = (-1L);
        struct CtdlMessage *old_msg = NULL;
        long history_msgnum = (-1L);
@@ -82,11 +81,10 @@ int wiki_upload_beforesave(struct CtdlMessage *msg, struct recptypes *recp) {
        long newmsgid;
        StrBuf *msgidbuf;
 
-       if (!CCC->logged_in) return(0); /* Only do this if logged in. */
+       if (!CC->logged_in) return(0);  /* Only do this if logged in. */
 
        /* Is this a room with a Wiki in it, don't run this hook. */
-       if ((CCC->room.QRdefaultview != VIEW_WIKI) &&
-           (CCC->room.QRdefaultview != VIEW_WIKIMD)) {
+       if (CC->room.QRdefaultview != VIEW_WIKI) {
                return(0);
        }
 
@@ -127,7 +125,7 @@ int wiki_upload_beforesave(struct CtdlMessage *msg, struct recptypes *recp) {
        CM_CopyField(msg, eMsgSubject, eExclusiveID);
 
        /* See if we can retrieve the previous version. */
-       old_msgnum = CtdlLocateMessageByEuid(msg->cm_fields[eExclusiveID], &CCC->room);
+       old_msgnum = CtdlLocateMessageByEuid(msg->cm_fields[eExclusiveID], &CC->room);
        if (old_msgnum > 0L) {
                old_msg = CtdlFetchMessage(old_msgnum, 1);
        }
@@ -207,7 +205,7 @@ int wiki_upload_beforesave(struct CtdlMessage *msg, struct recptypes *recp) {
 
        /* Now look for the existing edit history */
 
-       history_msgnum = CtdlLocateMessageByEuid(history_page, &CCC->room);
+       history_msgnum = CtdlLocateMessageByEuid(history_page, &CC->room);
        history_msg = NULL;
        if (history_msgnum > 0L) {
                history_msg = CtdlFetchMessage(history_msgnum, 1);
@@ -224,8 +222,8 @@ int wiki_upload_beforesave(struct CtdlMessage *msg, struct recptypes *recp) {
                history_msg->cm_anon_type = MES_NORMAL;
                history_msg->cm_format_type = FMT_RFC822;
                CM_SetField(history_msg, eAuthor, HKEY("Citadel"));
-               if (!IsEmptyStr(CCC->room.QRname)){
-                       CM_SetField(history_msg, eRecipient, CCC->room.QRname, strlen(CCC->room.QRname));
+               if (!IsEmptyStr(CC->room.QRname)){
+                       CM_SetField(history_msg, eRecipient, CC->room.QRname, strlen(CC->room.QRname));
                }
                CM_SetField(history_msg, eExclusiveID, history_page, history_page_len);
                CM_SetField(history_msg, eMsgSubject, history_page, history_page_len);
@@ -306,7 +304,7 @@ int wiki_upload_beforesave(struct CtdlMessage *msg, struct recptypes *recp) {
                        memolen = snprintf(memo, sizeof(memo), "%s|%ld|%s|%s", 
                                           uuid,
                                           Now,
-                                          CCC->user.fullname,
+                                          CC->user.fullname,
                                           CtdlGetConfigStr("c_nodename"));
 
                        memolen = CtdlEncodeBase64(encoded_memo, memo, memolen, 0);
@@ -491,7 +489,6 @@ void wiki_rev_callback(char *name, char *filename, char *partnum, char *disp,
  */
 void wiki_rev(char *pagename, char *rev, char *operation)
 {
-       struct CitContext *CCC = CC;
        int r;
        char history_page_name[270];
        long msgnum;
@@ -524,7 +521,7 @@ void wiki_rev(char *pagename, char *rev, char *operation)
        /* Begin by fetching the current version of the page.  We're going to patch
         * backwards through the diffs until we get the one we want.
         */
-       msgnum = CtdlLocateMessageByEuid(pagename, &CCC->room);
+       msgnum = CtdlLocateMessageByEuid(pagename, &CC->room);
        if (msgnum > 0L) {
                msg = CtdlFetchMessage(msgnum, 1);
        }
@@ -558,7 +555,7 @@ void wiki_rev(char *pagename, char *rev, char *operation)
        /* Get the revision history */
 
        snprintf(history_page_name, sizeof history_page_name, "%s_HISTORY_", pagename);
-       msgnum = CtdlLocateMessageByEuid(history_page_name, &CCC->room);
+       msgnum = CtdlLocateMessageByEuid(history_page_name, &CC->room);
        if (msgnum > 0L) {
                msg = CtdlFetchMessage(msgnum, 1);
        }
@@ -630,30 +627,30 @@ void wiki_rev(char *pagename, char *rev, char *operation)
                         * but only if the client fetches the message we just generated immediately
                         * without first trying to perform other fetch operations.
                         */
-                       if (CCC->cached_msglist != NULL) {
-                               free(CCC->cached_msglist);
-                               CCC->cached_msglist = NULL;
-                               CCC->cached_num_msgs = 0;
+                       if (CC->cached_msglist != NULL) {
+                               free(CC->cached_msglist);
+                               CC->cached_msglist = NULL;
+                               CC->cached_num_msgs = 0;
                        }
-                       CCC->cached_msglist = malloc(sizeof(long));
-                       if (CCC->cached_msglist != NULL) {
-                               CCC->cached_num_msgs = 1;
-                               CCC->cached_msglist[0] = msgnum;
+                       CC->cached_msglist = malloc(sizeof(long));
+                       if (CC->cached_msglist != NULL) {
+                               CC->cached_num_msgs = 1;
+                               CC->cached_msglist[0] = msgnum;
                        }
 
                }
                else if (!strcasecmp(operation, "revert")) {
                        CM_SetFieldLONG(msg, eTimestamp, time(NULL));
-                       if (!IsEmptyStr(CCC->user.fullname)) {
-                               CM_SetField(msg, eAuthor, CCC->user.fullname, strlen(CCC->user.fullname));
+                       if (!IsEmptyStr(CC->user.fullname)) {
+                               CM_SetField(msg, eAuthor, CC->user.fullname, strlen(CC->user.fullname));
                        }
 
-                       if (!IsEmptyStr(CCC->cs_inet_email)) {
-                               CM_SetField(msg, erFc822Addr, CCC->cs_inet_email, strlen(CCC->cs_inet_email));
+                       if (!IsEmptyStr(CC->cs_inet_email)) {
+                               CM_SetField(msg, erFc822Addr, CC->cs_inet_email, strlen(CC->cs_inet_email));
                        }
 
-                       if (!IsEmptyStr(CCC->room.QRname)) {
-                               CM_SetField(msg, eOriginalRoom, CCC->room.QRname, strlen(CCC->room.QRname));
+                       if (!IsEmptyStr(CC->room.QRname)) {
+                               CM_SetField(msg, eOriginalRoom, CC->room.QRname, strlen(CC->room.QRname));
                        }
 
                        if (!IsEmptyStr(pagename)) {
index 63bbf006c71f88c94445f37eb6380599fc1acb43..6e626ac52c5876ede82da970760bf599a0674f7f 100644 (file)
@@ -2712,7 +2712,6 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
 
        syslog(LOG_DEBUG, "msgbase: final selection: %s (%s)", actual_rm, room);
        if (strcasecmp(actual_rm, CC->room.QRname)) {
-               /* CtdlGetRoom(&CC->room, actual_rm); */
                CtdlUserGoto(actual_rm, 0, 1, NULL, NULL, NULL, NULL);
        }
 
index 44573dae34d985470c823f491b9005dba760efb8..9adc4d69e93ed9d66fa217ad82d68d30129c4884 100644 (file)
@@ -365,6 +365,10 @@ int CtdlGetRoom(struct ctdlroom *qrbuf, const char *room_name) {
 
        memset(qrbuf, 0, sizeof(struct ctdlroom));
 
+       if (IsEmptyStr(lowercase_name)) {
+               return(1);                      // empty room name , not valid
+       }
+
        /* First, try the public namespace */
        cdbqr = cdb_fetch(CDB_ROOMS, lowercase_name, strlen(lowercase_name));
 
index 0dc5ae3276b4909587f673041368b5f53cc2fc8a..473e83a80a8783c62ba938653a5e0c91599fbc5e 100644 (file)
@@ -84,9 +84,12 @@ int CtdlGetUser(struct ctdluser *usbuf, char *name)
        }
 
        makeuserkey(usernamekey, name);
+       if (IsEmptyStr(usernamekey)) {
+               return(1);      // empty user name
+       }
        cdbus = cdb_fetch(CDB_USERS, usernamekey, strlen(usernamekey));
 
-       if (cdbus == NULL) {    /* user not found */
+       if (cdbus == NULL) {    // user not found
                return(1);
        }
        if (usbuf != NULL) {
index 71bd0445415f64ea440ac0d5005fd3f326355861..701f0651f6d2efbb501fba653df5d7b4ad593388 100644 (file)
@@ -97,7 +97,6 @@ typedef enum _room_views {
        VIEW_DRAFTS             = 9,    /* Drafts view */
        VIEW_BLOG               = 10,   /* Blog view */
        VIEW_QUEUE              = 11,   /* SMTP/... QUEUE rooms */
-       VIEW_WIKIMD             = 12,   /* Markdown Wiki view */
        VIEW_MAX,
        VIEW_JSON_LIST,
 } ROOM_VIEWS;
index b3a848a9ddf80cbb2e0cb1abd002eb14aadadd03..76df63d21f35607f5abe38bd97d56d9fb7e385fc 100644 (file)
@@ -368,8 +368,7 @@ void dav_collection_list(void)
                        (view == VIEW_ADDRESSBOOK) ||
                        (view == VIEW_NOTES) ||
                        (view == VIEW_JOURNAL) ||
-                       (view == VIEW_WIKI) ||
-                       (view == VIEW_WIKIMD)
+                       (view == VIEW_WIKI)
                ) {
                        is_groupware_collection = 1;
                }
@@ -411,7 +410,6 @@ void dav_collection_list(void)
                                wc_printf("<G:vjournal-collection />");
                                break;
                        case VIEW_WIKI:
-                       case VIEW_WIKIMD:
                                wc_printf("<G:wiki-collection />");
                                break;
                        }
index 2dc7865b8763b5ae4201dd0ce9824554956a7f35..be4c628da140f31453327beb6f3d20f0e55fd88f 100644 (file)
@@ -1527,7 +1527,6 @@ InitModule_ROOMOPS
        REGISTERTokenParamDefine(VIEW_JOURNAL);
        REGISTERTokenParamDefine(VIEW_BLOG);
        REGISTERTokenParamDefine(VIEW_QUEUE);
-       REGISTERTokenParamDefine(VIEW_WIKIMD);          
 
        /* GNET types: */
        /* server internal, we need to know but ignore them. */
index 4a6448b8210d22c485320a75bc507ab957057862..50618e63608ef2609b10d20b45b911c21707f9b1 100644 (file)
@@ -147,7 +147,6 @@ void sitemap(void) {
                        sitemap_do_bbs();
                        break;
                case VIEW_WIKI:
-               case VIEW_WIKIMD:
                        sitemap_do_wiki();
                        break;
                case VIEW_BLOG:
index 5c522eb4a9612801867c8f10ae8ee7fc9d349340..390bf3cbea7e84203eca49ded48c5186552a05e5 100644 (file)
@@ -36,8 +36,7 @@ void display_wiki_page_backend(StrBuf *pagename, char *rev, int do_revert)
        long msgnum = (-1L);
        char buf[256];
 
-       if ((WC->CurRoom.view != VIEW_WIKI) &&
-           (WC->CurRoom.view != VIEW_WIKIMD)) {
+       if (WC->CurRoom.view != VIEW_WIKI) {
                wc_printf(_("'%s' is not a Wiki room."), ChrPtr(WC->CurRoom.name) );
                return;
        }
@@ -316,18 +315,6 @@ InitModule_WIKI
                NULL
        );
 
-       RegisterReadLoopHandlerset(
-               VIEW_WIKIMD,
-               wiki_GetParamsGetServerCall,
-               wiki_PrintHeaderPage,
-               NULL,
-               NULL,
-               NULL,
-               NULL,
-               wiki_Cleanup,
-               NULL
-       );
-
        WebcitAddUrlHandler(HKEY("wiki"), "", 0, display_wiki_page, 0);
        WebcitAddUrlHandler(HKEY("wiki_history"), "", 0, display_wiki_history, 0);
        WebcitAddUrlHandler(HKEY("wiki_pagelist"), "", 0, display_wiki_pagelist, 0);