=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/cgi.c,v retrieving revision 1.54 retrieving revision 1.55 diff -c -r1.54 -r1.55 *** src/usr.bin/mandoc/cgi.c 2015/11/07 17:58:52 1.54 --- src/usr.bin/mandoc/cgi.c 2015/12/25 20:16:19 1.55 *************** *** 1,4 **** ! /* $OpenBSD: cgi.c,v 1.54 2015/11/07 17:58:52 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2014, 2015 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: cgi.c,v 1.55 2015/12/25 20:16:19 bentley Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2014, 2015 Ingo Schwarze *************** *** 61,69 **** static void html_putchar(char); static int http_decode(char *); static void http_parse(struct req *, const char *); - static void http_print(const char *); - static void http_putchar(char); - static void http_printquery(const struct req *, const char *); static void pathgen(struct req *); static void pg_error_badrequest(const char *); static void pg_error_internal(void); --- 61,66 ---- *************** *** 147,186 **** } } - static void - http_printquery(const struct req *req, const char *sep) - { - - if (NULL != req->q.query) { - printf("query="); - http_print(req->q.query); - } - if (0 == req->q.equal) - printf("%sapropos=1", sep); - if (NULL != req->q.sec) { - printf("%ssec=", sep); - http_print(req->q.sec); - } - if (NULL != req->q.arch) { - printf("%sarch=", sep); - http_print(req->q.arch); - } - if (strcmp(req->q.manpath, req->p[0])) { - printf("%smanpath=", sep); - http_print(req->q.manpath); - } - } - - static void - http_print(const char *p) - { - - if (NULL == p) - return; - while ('\0' != *p) - http_putchar(*p++); - } - /* * Call through to html_putchar(). * Accepts NULL strings. --- 144,149 ---- *************** *** 301,320 **** } } - static void - http_putchar(char c) - { - - if (isalnum((unsigned char)c)) { - putchar((unsigned char)c); - return; - } else if (' ' == c) { - putchar('+'); - return; - } - printf("%%%.2x", c); - } - /* * HTTP-decode a string. The standard explanation is that this turns * "%4e+foo" into "n foo" in the regular way. This is done in-place --- 264,269 ---- *************** *** 621,629 **** * without any delay. */ printf("Status: 303 See Other\r\n"); ! printf("Location: http://%s%s/%s/%s?", HTTP_HOST, scriptname, req->q.manpath, r[0].file); - http_printquery(req, "&"); printf("\r\n" "Content-Type: text/html; charset=utf-8\r\n" "\r\n"); --- 570,577 ---- * without any delay. */ printf("Status: 303 See Other\r\n"); ! printf("Location: http://%s%s/%s/%s", HTTP_HOST, scriptname, req->q.manpath, r[0].file); printf("\r\n" "Content-Type: text/html; charset=utf-8\r\n" "\r\n"); *************** *** 638,646 **** for (i = 0; i < sz; i++) { printf("\n" "\n" ! "q.manpath, r[i].file); - http_printquery(req, "&"); printf("\">"); html_print(r[i].names); printf("\n" --- 586,593 ---- for (i = 0; i < sz; i++) { printf("\n" "\n" ! "q.manpath, r[i].file); printf("\">"); html_print(r[i].names); printf("\n"