From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id e3571f7f for ; Fri, 15 Apr 2016 10:13:37 -0500 (EST) Date: Fri, 15 Apr 2016 10:13:37 -0500 (EST) Message-Id: <9826820734502228327.enqueue@fantadrom.bsd.lv> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Fix parsing of PATH_INFO if both a section directory and an X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- Fix parsing of PATH_INFO if both a section directory and an architecture subdirectory are specified. Issue reported by tb@. Modified Files: -------------- mdocml: cgi.c Revision Data ------------- Index: cgi.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/cgi.c,v retrieving revision 1.126 retrieving revision 1.127 diff -Lcgi.c -Lcgi.c -u -p -r1.126 -r1.127 --- cgi.c +++ cgi.c @@ -1085,7 +1085,7 @@ main(void) static void path_parse(struct req *req, const char *path) { - int dir_done; + char *dir; req->isquery = 0; req->q.equal = 1; @@ -1115,23 +1115,19 @@ path_parse(struct req *req, const char * req->q.query = mandoc_strdup(req->q.query); /* Optional architecture. */ - dir_done = 0; - for (;;) { - if ((req->q.arch = strrchr(req->q.manpath, '/')) == NULL) - break; - *req->q.arch++ = '\0'; - if (dir_done || strncmp(req->q.arch, "man", 3)) { - req->q.arch = mandoc_strdup(req->q.arch); - break; - } - - /* Optional directory name. */ - req->q.arch += 3; - if (*req->q.arch != '\0') { - free(req->q.sec); - req->q.sec = mandoc_strdup(req->q.arch); - } - dir_done = 1; + dir = strrchr(req->q.manpath, '/'); + if (dir != NULL && strncmp(dir + 1, "man", 3) != 0) { + *dir++ = '\0'; + req->q.arch = mandoc_strdup(dir); + dir = strrchr(req->q.manpath, '/'); + } else + req->q.arch = NULL; + + /* Optional directory name. */ + if (dir != NULL && strncmp(dir + 1, "man", 3) == 0) { + *dir++ = '\0'; + free(req->q.sec); + req->q.sec = mandoc_strdup(dir + 3); } } -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv