summaryrefslogblamecommitdiff
path: root/system/mandoc/cgi-search.patch
blob: dd74be9efd637ef5fcf8fe58789b661a073a16f1 (plain) (tree)















































                                                                    
Don't exit immediately if mansearch returns some paths that man.cgi
considers invalid, in particular translated manpages (e.g.
./de/man1/chfn.1). Just mark them as invalid (section 10, see struct
manpage in mansearch.h) and skip them later.

--- 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
@@ -605,13 +602,20 @@ pg_searchres(const struct req *req, stru
 	size_t		 i, iuse;
 	int		 archprio, archpriouse;
 	int		 prio, priouse;
+	int		 results = 0;
 
 	for (i = 0; i < sz; i++) {
-		if (validate_filename(r[i].file))
+		if (validate_filename(r[i].file)) {
+			results = 1;
 			continue;
+		}
 		warnx("invalid filename %s in %s database",
 		    r[i].file, req->q.manpath);
-		pg_error_internal();
+		r[i].sec = 10;
+	}
+
+	if (! results) {
+		pg_noresult(req, "No results found.");
 		return;
 	}
 
@@ -642,6 +646,8 @@ pg_searchres(const struct req *req, stru
 		priouse = 20;
 		archpriouse = 3;
 		for (i = 0; i < sz; i++) {
+			if (r[i].sec == 10)
+				continue;
 			sec = r[i].file;
 			sec += strcspn(sec, "123456789");
 			if (sec[0] == '\0')
@@ -681,6 +687,8 @@ pg_searchres(const struct req *req, stru
 	if (sz > 1) {
 		puts("<table class=\"results\">");
 		for (i = 0; i < sz; i++) {
+			if (r[i].sec == 10)
+				continue;
 			printf("  <tr>\n"
 			       "    <td>"
 			       "<a class=\"Xr\" href=\"/");