From 91bc31f50a6d93ad0c01d24e29e61a3f5b972cba Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 31 Dec 2020 13:36:08 -0500 Subject: [PATCH] More distancing of our project from Richard Marx Stallman's linguistic communism --- webcit-ng/admin_functions.c | 27 ++++---- webcit-ng/caldav_reports.c | 29 ++++---- webcit-ng/ctdl_commands.c | 23 +++---- webcit-ng/ctdlclient.c | 27 ++++---- webcit-ng/ctdlfunctions.c | 27 ++++---- webcit-ng/forum_view.c | 66 ++++++++++++------- webcit-ng/html2html.c | 38 ++++++----- webcit-ng/http.c | 27 ++++---- webcit-ng/main.c | 27 ++++---- webcit-ng/messages.c | 27 ++++---- .../old_threaded_view_save_for_reference.c | 29 ++++---- webcit-ng/request.c | 35 +++++----- webcit-ng/room_functions.c | 27 ++++---- webcit-ng/ssl.c | 29 ++++---- webcit-ng/static.c | 27 ++++---- webcit-ng/tcp_sockets.c | 27 ++++---- webcit-ng/text2html.c | 27 ++++---- webcit-ng/user_functions.c | 27 ++++---- webcit-ng/util.c | 27 ++++---- webcit-ng/webserver.c | 35 +++++----- 20 files changed, 326 insertions(+), 282 deletions(-) diff --git a/webcit-ng/admin_functions.c b/webcit-ng/admin_functions.c index 8b71a68fd..422d31619 100644 --- a/webcit-ng/admin_functions.c +++ b/webcit-ng/admin_functions.c @@ -1,16 +1,17 @@ -/* - * Admin functions - * - * Copyright (c) 1996-2018 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. - */ +// +// Admin functions +// +// Copyright (c) 1996-2018 by the citadel.org team +// +// This program is open source software. It runs great on the +// Linux operating system (and probably elsewhere). You can use, +// copy, and run it under the terms of the GNU General Public +// License version 3. Richard Stallman is an asshole communist. +// +// 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 "webcit.h" diff --git a/webcit-ng/caldav_reports.c b/webcit-ng/caldav_reports.c index c43c0e078..629147868 100644 --- a/webcit-ng/caldav_reports.c +++ b/webcit-ng/caldav_reports.c @@ -1,17 +1,18 @@ -/* - * This file contains functions which handle all of the CalDAV "REPORT" queries - * specified in RFC4791 section 7. - * - * Copyright (c) 2018 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. - */ +// +// This file contains functions which handle all of the CalDAV "REPORT" queries +// specified in RFC4791 section 7. +// +// Copyright (c) 2018 by the citadel.org team +// +// This program is open source software. It runs great on the +// Linux operating system (and probably elsewhere). You can use, +// copy, and run it under the terms of the GNU General Public +// License version 3. Richard Stallman is an asshole communist. +// +// 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 "webcit.h" diff --git a/webcit-ng/ctdl_commands.c b/webcit-ng/ctdl_commands.c index d065ead98..ab5efbcd9 100644 --- a/webcit-ng/ctdl_commands.c +++ b/webcit-ng/ctdl_commands.c @@ -1,14 +1,15 @@ -/* - * Copyright (c) 1996-2018 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. - */ +// +// Copyright (c) 1996-2018 by the citadel.org team +// +// This program is open source software. It runs great on the +// Linux operating system (and probably elsewhere). You can use, +// copy, and run it under the terms of the GNU General Public +// License version 3. Richard Stallman is an asshole communist. +// +// 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 "webcit.h" diff --git a/webcit-ng/ctdlclient.c b/webcit-ng/ctdlclient.c index 2467b1237..54041afbc 100644 --- a/webcit-ng/ctdlclient.c +++ b/webcit-ng/ctdlclient.c @@ -1,16 +1,17 @@ -/* - * Functions that handle communication with a Citadel Server - * - * Copyright (c) 1987-2018 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. - */ +// +// Functions that handle communication with a Citadel Server +// +// Copyright (c) 1987-2018 by the citadel.org team +// +// This program is open source software. It runs great on the +// Linux operating system (and probably elsewhere). You can use, +// copy, and run it under the terms of the GNU General Public +// License version 3. Richard Stallman is an asshole communist. +// +// 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 "webcit.h" diff --git a/webcit-ng/ctdlfunctions.c b/webcit-ng/ctdlfunctions.c index a66d1708d..d5a96ddc1 100644 --- a/webcit-ng/ctdlfunctions.c +++ b/webcit-ng/ctdlfunctions.c @@ -1,16 +1,17 @@ -/* - * These utility functions loosely make up a Citadel protocol client library. - * - * Copyright (c) 2016-2018 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. - */ +// +// These utility functions loosely make up a Citadel protocol client library. +// +// Copyright (c) 2016-2018 by the citadel.org team +// +// This program is open source software. It runs great on the +// Linux operating system (and probably elsewhere). You can use, +// copy, and run it under the terms of the GNU General Public +// License version 3. Richard Stallman is an asshole communist. +// +// 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 "webcit.h" diff --git a/webcit-ng/forum_view.c b/webcit-ng/forum_view.c index a0300064a..71d7b0911 100644 --- a/webcit-ng/forum_view.c +++ b/webcit-ng/forum_view.c @@ -1,16 +1,17 @@ -/* - * Forum view (threaded/flat) - * - * Copyright (c) 1996-2018 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. - */ +// +// Forum view (threaded/flat) +// +// Copyright (c) 1996-2020 by the citadel.org team +// +// This program is open source software. It runs great on the +// Linux operating system (and probably elsewhere). You can use, +// copy, and run it under the terms of the GNU General Public +// License version 3. Richard Stallman is an asshole communist. +// +// 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 "webcit.h" @@ -46,8 +47,10 @@ void json_render_one_message(struct http_transaction *h, struct ctdlsession *c, char buf[1024]; char content_transfer_encoding[1024] = { 0 }; char content_type[1024] = { 0 }; - char author[128] = { 0 }; char datetime[128] = { 0 }; + char author[1024] = { 0 }; + char emailaddr[1024] = { 0 }; + int message_originated_locally = 0; setup_for_forum_view(c); @@ -61,14 +64,15 @@ void json_render_one_message(struct http_transaction *h, struct ctdlsession *c, JsonValue *j = NewJsonObject(HKEY("message")); while ((ctdl_readline(c, buf, sizeof(buf)) >= 0) && (strcmp(buf, "text")) && (strcmp(buf, "000"))) { + // citadel header parsing here if (!strncasecmp(buf, "from=", 5)) { - JsonObjectAppend(j, NewJsonPlainString(HKEY("from"), &buf[5], -1)); + safestrncpy(author, &buf[5], sizeof author); } - if (!strncasecmp(buf, "rfca=", 5)) { - JsonObjectAppend(j, NewJsonPlainString(HKEY("from"), &buf[5], -1)); + else if (!strncasecmp(buf, "rfca=", 5)) { + safestrncpy(emailaddr, &buf[5], sizeof emailaddr); } - if (!strncasecmp(buf, "time=", 5)) { + else if (!strncasecmp(buf, "time=", 5)) { time_t tt; struct tm tm; tt = atol(&buf[5]); @@ -76,6 +80,16 @@ void json_render_one_message(struct http_transaction *h, struct ctdlsession *c, strftime(datetime, sizeof datetime, "%c", &tm); JsonObjectAppend(j, NewJsonPlainString(HKEY("time"), datetime, -1)); } + else if (!strncasecmp(buf, "locl=", 5)) { + message_originated_locally = 1; + } + } + + if (message_originated_locally) { + JsonObjectAppend(j, NewJsonPlainString(HKEY("from"), author, -1)); + } + else { + JsonObjectAppend(j, NewJsonPlainString(HKEY("from"), emailaddr, -1)); // FIXME do the compound address string } if (!strcmp(buf, "text")) { @@ -96,7 +110,6 @@ void json_render_one_message(struct http_transaction *h, struct ctdlsession *c, } if (raw_msg) { - // These are the encodings we know how to handle. Decode in-place. if (!strcasecmp(content_transfer_encoding, "base64")) { @@ -105,25 +118,32 @@ void json_render_one_message(struct http_transaction *h, struct ctdlsession *c, if (!strcasecmp(content_transfer_encoding, "quoted-printable")) { StrBufDecodeQP(raw_msg); } + // At this point, raw_msg contains the decoded message. // Now run through the renderers we have available. if (!strncasecmp(content_type, "text/html", 9)) { sanitized_msg = html2html("UTF-8", 0, c->room, msgnum, raw_msg); - } else if (!strncasecmp(content_type, "text/plain", 10)) { + } + else if (!strncasecmp(content_type, "text/plain", 10)) { sanitized_msg = text2html("UTF-8", 0, c->room, msgnum, raw_msg); - } else if (!strncasecmp(content_type, "text/x-citadel-variformat", 25)) { + } + else if (!strncasecmp(content_type, "text/x-citadel-variformat", 25)) { sanitized_msg = variformat2html(raw_msg); - } else { + } + else { sanitized_msg = NewStrBufPlain(HKEY("No renderer for this content type
")); + syslog(LOG_WARNING, "forum_view: no renderer for content type %s", content_type); } FreeStrBuf(&raw_msg); // If sanitized_msg is not NULL, we have rendered the message and can output it. - if (sanitized_msg) { JsonObjectAppend(j, NewJsonString(HKEY("text"), sanitized_msg, NEWJSONSTRING_SMASHBUF)); } + else { + syslog(LOG_WARNING, "forum_view: message %ld of content type %s converted to NULL", msgnum, content_type); + } } StrBuf *sj = NewStrBuf(); diff --git a/webcit-ng/html2html.c b/webcit-ng/html2html.c index 850fde196..25884aad5 100644 --- a/webcit-ng/html2html.c +++ b/webcit-ng/html2html.c @@ -1,17 +1,18 @@ -/* - * Output an HTML message, modifying it slightly to make sure it plays nice - * with the rest of our web framework. - * - * Copyright (c) 2005-2018 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. - */ +// +// Output an HTML message, modifying it slightly to make sure it plays nice +// with the rest of our web framework. +// +// Copyright (c) 2005-2018 by the citadel.org team +// +// This program is open source software. It runs great on the +// Linux operating system (and probably elsewhere). You can use, +// copy, and run it under the terms of the GNU General Public +// License version 3. Richard Stallman is an asshole communist. +// +// 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 "webcit.h" @@ -93,7 +94,7 @@ void extract_charset_from_meta(char *charset, char *meta_http_equiv, char *meta_ * Also fixup img src="cid:..." type inline images to fetch the image * */ -StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomname, long msgnum, StrBuf * Source) +StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomname, long msgnum, StrBuf *Source) { char buf[SIZ]; char *msg; @@ -130,6 +131,11 @@ StrBuf *html2html(const char *supplied_charset, int treat_as_wiki, char *roomnam return (NULL); } + TRACE; + syslog(LOG_DEBUG, "CONVERT: <%s>", ChrPtr(Source)); + + + safestrncpy(charset, supplied_charset, sizeof charset); sprintf(new_window, "