From 550361815d6a1cf261e99ad2b430433ef6966e1a Mon Sep 17 00:00:00 2001 From: Max Rees Date: Fri, 5 Jun 2020 16:45:20 -0500 Subject: system/mandoc: new package --- system/mandoc/cgi-gz.patch | 77 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 system/mandoc/cgi-gz.patch (limited to 'system/mandoc/cgi-gz.patch') diff --git a/system/mandoc/cgi-gz.patch b/system/mandoc/cgi-gz.patch new file mode 100644 index 000000000..ac506b797 --- /dev/null +++ b/system/mandoc/cgi-gz.patch @@ -0,0 +1,77 @@ +Handle the case where some of the entries in the manpath are gzipped by +removing the .gz extension and allowing mparse_open to add it back and +mark the page as gzipped. This is part of the documented contract for +mparse_open, see mandoc(3). + +--- mandoc-1.14.5/cgi.c 2019-03-10 04:56:43.000000000 -0500 ++++ mandoc-1.14.5/cgi.c 2020-06-05 15:54:05.681060852 -0500 +@@ -93,7 +93,7 @@ static void resp_searchform(const stru + static void resp_show(const struct req *, const char *); + static void set_query_attr(char **, char **); + static int validate_arch(const char *); +-static int validate_filename(const char *); ++static int validate_filename(char *); + static int validate_manpath(const struct req *, const char *); + static int validate_urifrag(const char *); + +@@ -517,8 +509,13 @@ validate_arch(const char *arch) + } + + static int +-validate_filename(const char *file) ++validate_filename(char *file) + { ++ char *cp; ++ ++ cp = strrchr(file, '.'); ++ if (cp != NULL && ! strcmp(cp + 1, "gz")) ++ *cp = '\0'; + + if ('.' == file[0] && '/' == file[1]) + file += 2; +@@ -854,14 +862,15 @@ resp_format(const struct req *req, const + int fd; + int usepath; + +- if (-1 == (fd = open(file, O_RDONLY, 0))) { +- puts("

You specified an invalid manual file.

"); +- return; +- } +- + mchars_alloc(); + mp = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1 | + MPARSE_VALIDATE, MANDOC_OS_OTHER, req->q.manpath); ++ ++ if (-1 == (fd = mparse_open(mp, file))) { ++ puts("

You specified an invalid manual file.

"); ++ goto out; ++ } ++ + mparse_readfd(mp, fd, file); + close(fd); + meta = mparse_result(mp); +@@ -882,10 +891,11 @@ resp_format(const struct req *req, const + html_man(vp, meta); + + html_free(vp); +- mparse_free(mp); +- mchars_free(); + free(conf.man); + free(conf.style); ++out: ++ mparse_free(mp); ++ mchars_free(); + } + + static void +@@ -904,8 +914,8 @@ resp_show(const struct req *req, const c + static void + pg_show(struct req *req, const char *fullpath) + { +- char *manpath; +- const char *file; ++ char *manpath; ++ char *file; + + if ((file = strchr(fullpath, '/')) == NULL) { + pg_error_badrequest( -- cgit v1.2.3-70-g09d2