source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Fix parsing of PATH_INFO if both a section directory and an
Date: Fri, 15 Apr 2016 10:13:37 -0500 (EST)	[thread overview]
Message-ID: <9826820734502228327.enqueue@fantadrom.bsd.lv> (raw)

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

                 reply	other threads:[~2016-04-15 15:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9826820734502228327.enqueue@fantadrom.bsd.lv \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).