* mdocml: Fix parsing of PATH_INFO if both a section directory and an
@ 2016-04-15 15:13 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2016-04-15 15:13 UTC (permalink / raw)
To: source
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-04-15 15:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-15 15:13 mdocml: Fix parsing of PATH_INFO if both a section directory and an schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).