changeset 930:2477f43a937e

req: convert p/paged/m/preview query string values to ints Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Thu, 07 Sep 2017 17:00:18 +0300
parents 179c14532888
children fb4b67fa1223
files req.c
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/req.c	Thu Sep 07 16:54:52 2017 +0300
+++ b/req.c	Thu Sep 07 17:00:18 2017 +0300
@@ -235,6 +235,14 @@
 	ASSERT0(ret);
 }
 
+static const struct nvl_convert_info info[] = {
+	{ .name = "p",       .tgt_type = NVT_INT, },
+	{ .name = "paged",   .tgt_type = NVT_INT, },
+	{ .name = "m",       .tgt_type = NVT_INT, },
+	{ .name = "preview", .tgt_type = NVT_INT, },
+	{ .name = NULL, },
+};
+
 static bool select_page(struct req *req)
 {
 	struct nvlist *query = req->scgi->request.query;
@@ -308,6 +316,8 @@
 			*cptr = val;
 	}
 
+	(void) nvl_convert(query, info, true);
+
 	if (args->comment)
 		args->page = PAGE_COMMENT;
 	else if (args->tag)