From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20397 invoked from network); 5 Jul 2022 14:04:57 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 5 Jul 2022 14:04:57 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id ccd788ec for ; Tue, 5 Jul 2022 09:04:55 -0500 (EST) Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id b99d8e0b for ; Tue, 5 Jul 2022 09:04:55 -0500 (EST) Date: Tue, 5 Jul 2022 09:04:55 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: Somehow, the content of header.html ended up before and outside X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: <336655cb3b35dd8f@mandoc.bsd.lv> Log Message: ----------- Somehow, the content of header.html ended up before and outside the
element. Fix this by moving it into the
element where it belongs. While here, also wrap footer.html in a
element. Modified Files: -------------- mandoc: cgi.c Revision Data ------------- Index: cgi.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/cgi.c,v retrieving revision 1.177 retrieving revision 1.178 diff -Lcgi.c -Lcgi.c -u -p -r1.177 -r1.178 --- cgi.c +++ cgi.c @@ -1,6 +1,6 @@ /* $Id$ */ /* - * Copyright (c) 2014-2019, 2021 Ingo Schwarze + * Copyright (c) 2014-2019, 2021, 2022 Ingo Schwarze * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2022 Anna Vyalkova * @@ -87,10 +87,10 @@ static void pg_search(const struct req static void pg_searchres(const struct req *, struct manpage *, size_t); static void pg_show(struct req *, const char *); -static void resp_begin_html(int, const char *, const char *); +static int resp_begin_html(int, const char *, const char *); static void resp_begin_http(int, const char *); static void resp_catman(const struct req *, const char *); -static void resp_copy(const char *); +static int resp_copy(const char *, const char *); static void resp_end_html(void); static void resp_format(const struct req *, const char *); static void resp_searchform(const struct req *, enum focus); @@ -353,22 +353,26 @@ resp_begin_http(int code, const char *ms fflush(stdout); } -static void -resp_copy(const char *filename) +static int +resp_copy(const char *element, const char *filename) { char buf[4096]; ssize_t sz; int fd; - if ((fd = open(filename, O_RDONLY)) != -1) { - fflush(stdout); - while ((sz = read(fd, buf, sizeof(buf))) > 0) - write(STDOUT_FILENO, buf, sz); - close(fd); - } + if ((fd = open(filename, O_RDONLY)) == -1) + return 0; + + if (element != NULL) + printf("<%s>\n", element); + fflush(stdout); + while ((sz = read(fd, buf, sizeof(buf))) > 0) + write(STDOUT_FILENO, buf, sz); + close(fd); + return 1; } -static void +static int resp_begin_html(int code, const char *msg, const char *file) { const char *name, *sec, *cp; @@ -414,14 +418,14 @@ resp_begin_html(int code, const char *ms "\n", CUSTOMIZE_TITLE); - resp_copy(MAN_DIR "/header.html"); + return resp_copy("header", MAN_DIR "/header.html"); } static void resp_end_html(void) { - - resp_copy(MAN_DIR "/footer.html"); + if (resp_copy("footer", MAN_DIR "/footer.html")) + puts("
"); puts("\n" ""); @@ -432,8 +436,7 @@ resp_searchform(const struct req *req, e { int i; - printf("
\n" - "
\n" "
\n" " Manual Page Search Parameters\n", @@ -501,8 +504,7 @@ resp_searchform(const struct req *req, e } puts("
\n" - "
\n" - "
"); + ""); } static int @@ -557,10 +559,11 @@ validate_filename(const char *file) static void pg_index(const struct req *req) { - - resp_begin_html(200, NULL, NULL); + if (resp_begin_html(200, NULL, NULL) == 0) + puts("
"); resp_searchform(req, FOCUS_QUERY); - printf("
\n" + printf("
\n" + "
\n" "

\n" "This web interface is documented in the\n" ""); resp_searchform(req, FOCUS_QUERY); + puts("

"); puts("
"); puts("

"); puts(user_msg); @@ -593,8 +598,8 @@ pg_noresult(const struct req *req, int c static void pg_error_badrequest(const char *msg) { - - resp_begin_html(400, "Bad Request", NULL); + if (resp_begin_html(400, "Bad Request", NULL)) + puts("

"); puts("
\n" "

Bad Request

\n" "

"); @@ -602,14 +607,15 @@ pg_error_badrequest(const char *msg) printf("Try again from the\n" "main page.\n" "

\n" - "
", scriptname); + "\n", scriptname); resp_end_html(); } static void pg_error_internal(void) { - resp_begin_html(500, "Internal Server Error", NULL); + if (resp_begin_html(500, "Internal Server Error", NULL)) + puts(""); puts("

Internal Server Error

"); resp_end_html(); } @@ -641,6 +647,7 @@ pg_searchres(const struct req *req, stru size_t i, iuse; int archprio, archpriouse; int prio, priouse; + int have_header; for (i = 0; i < sz; i++) { if (validate_filename(r[i].file)) @@ -707,12 +714,15 @@ pg_searchres(const struct req *req, stru priouse = prio; iuse = i; } - resp_begin_html(200, NULL, r[iuse].file); + have_header = resp_begin_html(200, NULL, r[iuse].file); } else - resp_begin_html(200, NULL, NULL); + have_header = resp_begin_html(200, NULL, NULL); + if (have_header == 0) + puts("
"); resp_searchform(req, req->q.equal || sz == 1 ? FOCUS_NONE : FOCUS_QUERY); + puts("
"); if (sz > 1) { puts("