From c610deab77612b51cb238f62acc87fb17726cbff Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 14 Aug 2013 10:43:11 -0400 Subject: [PATCH] Adjusted paramhandling to accept parameters with empty values (which is legal) --- webcit/calendar.h | 8 +------- webcit/dav.h | 16 ++++++++++++++-- webcit/messages.h | 12 ++++++++++++ webcit/paramhandling.c | 32 +++++++++++++++++++------------- webcit/paramhandling.h | 12 ++++++++++++ webcit/preferences.h | 12 ++++++++++++ webcit/roomops.h | 29 ++++++++++++++++++++--------- webcit/subst.h | 14 ++++++++++++-- webcit/tcp_sockets.h | 40 +++++++++++++++++++++++++--------------- webcit/utils.h | 12 ++++++++++++ webcit/webserver.h | 12 ++++++++++++ 11 files changed, 151 insertions(+), 48 deletions(-) diff --git a/webcit/calendar.h b/webcit/calendar.h index a5571a0e4..ee1f8bc6a 100644 --- a/webcit/calendar.h +++ b/webcit/calendar.h @@ -1,19 +1,13 @@ /* - * Copyright (c) 1996-2012 by the citadel.org team + * Copyright (c) 1996-2013 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. - * - * - * - * */ #ifndef __CALENDAR_H__ diff --git a/webcit/dav.h b/webcit/dav.h index a2963f0fb..3426c81cd 100644 --- a/webcit/dav.h +++ b/webcit/dav.h @@ -1,6 +1,18 @@ /* - * Data passed back and forth between dav_get() and its - * callback functions called by the MIME parser + * Copyright (c) 1996-2013 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. + */ + + +/* + * Data passed back and forth between dav_get() and its callback functions called by the MIME parser */ struct epdata { char desired_content_type_1[128]; diff --git a/webcit/messages.h b/webcit/messages.h index 050117b0e..0738e947e 100644 --- a/webcit/messages.h +++ b/webcit/messages.h @@ -1,3 +1,15 @@ +/* + * Copyright (c) 1996-2013 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. + */ + extern CtxType CTX_MAILSUM; extern CtxType CTX_MIME_ATACH; extern HashList *MsgHeaderHandler; diff --git a/webcit/paramhandling.c b/webcit/paramhandling.c index a317ad39d..f7d1a325d 100644 --- a/webcit/paramhandling.c +++ b/webcit/paramhandling.c @@ -1,7 +1,7 @@ /* * parse urlparts and post data * - * Copyright (c) 1996-2012 by the citadel.org team + * Copyright (c) 1996-2013 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. @@ -15,6 +15,10 @@ #include "webcit.h" #include "webserver.h" +/* uncomment to see all parameters sent to the server by the browser. */ +/* #define DEBUG_URLSTRINGS */ + + void free_url(void *U) { urlcontent *u = (urlcontent*) U; @@ -27,19 +31,21 @@ void free_url(void *U) */ void ParseURLParams(StrBuf *url) { - const char *aptr, *bptr, *eptr, *up; - int len, keylen; - urlcontent *u; + const char *aptr, *bptr, *eptr, *up = NULL; + int len, keylen = 0; + urlcontent *u = NULL; wcsession *WCC = WC; - if (WCC->Hdr->urlstrings == NULL) + if (WCC->Hdr->urlstrings == NULL) { WCC->Hdr->urlstrings = NewHash(1, NULL); + } eptr = ChrPtr(url) + StrLength(url); up = ChrPtr(url); while ((up < eptr) && (!IsEmptyStr(up))) { aptr = up; - while ((aptr < eptr) && (*aptr != '\0') && (*aptr != '=')) + while ((aptr < eptr) && (*aptr != '\0') && (*aptr != '=')) { aptr++; + } if (*aptr != '=') { return; } @@ -50,16 +56,17 @@ void ParseURLParams(StrBuf *url) bptr++; } keylen = aptr - up - 1; /* -1 -> '=' */ - if(keylen >= sizeof(u->url_key)) { - syslog(LOG_WARNING, "invalid url_key from %s", ChrPtr(WCC->Hdr->HR.browser_host)); - return; + if (keylen > sizeof(u->url_key)) { + syslog(LOG_WARNING, "%s:%d: invalid url_key of size %d in string size %d", + __FILE__, __LINE__, keylen, sizeof(u->url_key) + ); } u = (urlcontent *) malloc(sizeof(urlcontent)); memcpy(u->url_key, up, keylen); u->url_key[keylen] = '\0'; if (keylen < 0) { - syslog(LOG_WARNING, "invalid url_key from %s", ChrPtr(WCC->Hdr->HR.browser_host)); + syslog(LOG_WARNING, "%s:%d: invalid url_key of size %d", __FILE__, __LINE__, keylen); free(u); return; } @@ -357,7 +364,7 @@ void upload_handler(char *name, char *filename, char *partnum, char *disp, WCC->upload_filename = NewStrBufPlain(filename, -1); safestrncpy(WCC->upload_content_type, cbtype, sizeof(WC->upload_content_type)); #ifdef DEBUG_URLSTRINGS - syslog(LOG_DEBUG, "File: <%s> len: [%ld]", filename, length); + syslog(LOG_DEBUG, "File: <%s> len: [%ld]", filename, (long int)length); #endif } @@ -367,10 +374,9 @@ void upload_handler(char *name, char *filename, char *partnum, char *disp, void PutBstr(const char *key, long keylen, StrBuf *Value) { urlcontent *u; - wcsession *WCC = WC; if(keylen >= sizeof(u->url_key)) { - syslog(LOG_WARNING, "invalid url_key from %s", ChrPtr(WCC->Hdr->HR.browser_host)); + syslog(LOG_WARNING, "%s:%d: invalid url_key of size %ld", __FILE__, __LINE__, keylen); FreeStrBuf(&Value); return; } diff --git a/webcit/paramhandling.h b/webcit/paramhandling.h index 87b0b1cec..4aaddea71 100644 --- a/webcit/paramhandling.h +++ b/webcit/paramhandling.h @@ -1,3 +1,15 @@ +/* + * Copyright (c) 1996-2013 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. + */ + /* URL / Mime Post parsing -> paramhandling.c */ void upload_handler(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, diff --git a/webcit/preferences.h b/webcit/preferences.h index 7a3c04300..7a30a7bbd 100644 --- a/webcit/preferences.h +++ b/webcit/preferences.h @@ -1,3 +1,15 @@ +/* + * Copyright (c) 1996-2013 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. + */ + typedef enum _ePrefType{ PRF_UNSET = 0, diff --git a/webcit/roomops.h b/webcit/roomops.h index 7d9cd89e3..fd1f60e4a 100644 --- a/webcit/roomops.h +++ b/webcit/roomops.h @@ -1,8 +1,20 @@ +/* + * Copyright (c) 1996-2013 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. + */ + #define VIRTUAL_MY_FLOOR -1 /* - * \brief This struct holds a list of rooms for \\\oto operations. + * This struct holds a list of rooms for "Goto" operations. */ struct march { struct march *next; /* pointer to next in linked list */ @@ -11,9 +23,8 @@ struct march { int march_order; /* sequence in which we are to visit this room */ }; -/* * - * \brief This struct holds a list of rooms for client display. - * It is a binary tree. +/* + * This struct holds a list of rooms for client display. It is a binary tree. */ struct roomlisting { struct roomlisting *lnext; /* pointer to 'left' tree node */ @@ -35,8 +46,8 @@ typedef struct _floor { long AlphaN; } Floor; -/** - * \brief Data structure for roomlist-to-folderlist conversion +/* + * Data structure for roomlist-to-folderlist conversion */ struct __ofolder { int floor; /* which floor is it on */ @@ -51,8 +62,8 @@ struct __ofolder { -/** - * \brief Data structure for roomlist-to-folderlist conversion +/* + * Data structure for roomlist-to-folderlist conversion */ typedef struct _folder { /* Data citserver tells us about the room */ @@ -108,7 +119,7 @@ typedef struct _folder { int BumpUsers; /* if SETR set to 1 to make all users who knew this room to forget about it. */ HashList *IgnetCfgs[maxRoomNetCfg + 1]; -}folder; +} folder; HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP); void vDeleteFolder(void *vFolder); diff --git a/webcit/subst.h b/webcit/subst.h index 30c3a6b66..bd6f8318d 100644 --- a/webcit/subst.h +++ b/webcit/subst.h @@ -1,5 +1,15 @@ -/** - * @defgroup subst Template processing functions +/* + * Copyright (c) 1996-2013 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. + * + * subst template processing functions */ extern HashList *Conditionals; diff --git a/webcit/tcp_sockets.h b/webcit/tcp_sockets.h index a8bfb20ca..8528539bf 100644 --- a/webcit/tcp_sockets.h +++ b/webcit/tcp_sockets.h @@ -1,26 +1,36 @@ +/* + * Copyright (c) 1996-2013 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. + */ + int uds_connectsock(char *); int tcp_connectsock(char *, char *); int serv_getln(char *strbuf, int bufsize); int StrBuf_ServGetln(StrBuf *buf); -/** - * @defgroup CoreSrv Core Server Functionality +/* + * parse & check the server reply + * + * Line the line containing the server reply + * FullState if you need more than just the major number, this is returns it. Ignored if NULL. + * PutImportantMessage if you want to forward the text part of the server reply to the user, specify 1; + * the result will be put into the 'Important Message' framework. + * MajorOK in case of which major number not to put the ImportantMessage? 0 for all. + * + * returns the most significant digit of the server status */ -/** - * @ingroup CoreSrv - * @brief parse & check the server reply - * @param Line the line containing the server reply - * @param FullState if you need more than just the major number, this is returns it. Ignored if NULL. - * @param PutImportantMessage if you want to forward the text part of the server reply to the user, specify 1; - * the result will be put into the 'Important Message' framework. - * @param MajorOK in case of which major number not to put the ImportantMessage? 0 for all. - * @return the most significant digit of the server status - */ int GetServerStatusMsg(StrBuf *Line, long* FullState, int PutImportantMessage, int MajorOK); -/** - * @ingroup CoreSrv - * @brief to migrate old calls.... + +/* + * to migrate old calls.... */ #define GetServerStatus(a, b) GetServerStatusMsg(a, b, 0, 0) diff --git a/webcit/utils.h b/webcit/utils.h index 57cf13b9f..7c322492b 100644 --- a/webcit/utils.h +++ b/webcit/utils.h @@ -1,3 +1,15 @@ +/* + * Copyright (c) 1996-2013 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. + */ + void StrEscPuts(const StrBuf *strbuf); void StrEscputs1(const StrBuf *strbuf, int nbsp, int nolinebreaks); diff --git a/webcit/webserver.h b/webcit/webserver.h index 51926cbf5..dc142d0d1 100644 --- a/webcit/webserver.h +++ b/webcit/webserver.h @@ -1,3 +1,15 @@ +/* + * Copyright (c) 1996-2013 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. + */ + extern char *static_dirs[PATH_MAX]; /**< Web representation */ extern int ndirs; -- 2.30.2