version 1.86, 2014/07/25 17:34:06 |
version 1.90, 2014/07/25 20:09:09 |
|
|
http_printquery(const struct req *req) |
http_printquery(const struct req *req) |
{ |
{ |
|
|
if (NULL != req->q.manpath) { |
if (NULL != req->q.query) { |
printf("&manpath="); |
printf("query="); |
http_print(req->q.manpath); |
http_print(req->q.query); |
} |
} |
|
if (0 == req->q.equal) |
|
printf("&apropos=1"); |
if (NULL != req->q.sec) { |
if (NULL != req->q.sec) { |
printf("&sec="); |
printf("&sec="); |
http_print(req->q.sec); |
http_print(req->q.sec); |
Line 160 http_printquery(const struct req *req) |
|
Line 162 http_printquery(const struct req *req) |
|
printf("&arch="); |
printf("&arch="); |
http_print(req->q.arch); |
http_print(req->q.arch); |
} |
} |
if (NULL != req->q.query) { |
if (NULL != req->q.manpath && |
printf("&query="); |
strcmp(req->q.manpath, req->p[0])) { |
http_print(req->q.query); |
printf("&manpath="); |
|
http_print(req->q.manpath); |
} |
} |
if (0 == req->q.equal) |
|
printf("&apropos=1"); |
|
} |
} |
|
|
static void |
static void |
html_printquery(const struct req *req) |
html_printquery(const struct req *req) |
{ |
{ |
|
|
if (NULL != req->q.manpath) { |
if (NULL != req->q.query) { |
printf("&manpath="); |
printf("query="); |
html_print(req->q.manpath); |
html_print(req->q.query); |
} |
} |
|
if (0 == req->q.equal) |
|
printf("&apropos=1"); |
if (NULL != req->q.sec) { |
if (NULL != req->q.sec) { |
printf("&sec="); |
printf("&sec="); |
html_print(req->q.sec); |
html_print(req->q.sec); |
Line 184 html_printquery(const struct req *req) |
|
Line 187 html_printquery(const struct req *req) |
|
printf("&arch="); |
printf("&arch="); |
html_print(req->q.arch); |
html_print(req->q.arch); |
} |
} |
if (NULL != req->q.query) { |
if (NULL != req->q.manpath && |
printf("&query="); |
strcmp(req->q.manpath, req->p[0])) { |
html_print(req->q.query); |
printf("&manpath="); |
|
html_print(req->q.manpath); |
} |
} |
if (0 == req->q.equal) |
|
printf("&apropos=1"); |
|
} |
} |
|
|
static void |
static void |
|
|
format(const struct req *req, const char *file) |
format(const struct req *req, const char *file) |
{ |
{ |
struct mparse *mp; |
struct mparse *mp; |
int fd; |
|
struct mdoc *mdoc; |
struct mdoc *mdoc; |
struct man *man; |
struct man *man; |
void *vp; |
void *vp; |
|
char *opts; |
enum mandoclevel rc; |
enum mandoclevel rc; |
char opts[PATH_MAX + 128]; |
int fd; |
|
int usepath; |
|
|
if (-1 == (fd = open(file, O_RDONLY, 0))) { |
if (-1 == (fd = open(file, O_RDONLY, 0))) { |
puts("<P>You specified an invalid manual file.</P>"); |
puts("<P>You specified an invalid manual file.</P>"); |
Line 873 format(const struct req *req, const char *file) |
|
Line 876 format(const struct req *req, const char *file) |
|
return; |
return; |
} |
} |
|
|
snprintf(opts, sizeof(opts), "fragment,man=%s?" |
usepath = strcmp(req->q.manpath, req->p[0]); |
"manpath=%s&query=%%N&sec=%%S&arch=%s", |
mandoc_asprintf(&opts, |
scriptname, req->q.manpath, |
"fragment,man=%s?query=%%N&sec=%%S%s%s%s%s", |
req->q.arch ? req->q.arch : ""); |
scriptname, |
|
req->q.arch ? "&arch=" : "", |
|
req->q.arch ? req->q.arch : "", |
|
usepath ? "&manpath=" : "", |
|
usepath ? req->q.manpath : ""); |
|
|
mparse_result(mp, &mdoc, &man, NULL); |
mparse_result(mp, &mdoc, &man, NULL); |
if (NULL == man && NULL == mdoc) { |
if (NULL == man && NULL == mdoc) { |
Line 896 format(const struct req *req, const char *file) |
|
Line 903 format(const struct req *req, const char *file) |
|
|
|
html_free(vp); |
html_free(vp); |
mparse_free(mp); |
mparse_free(mp); |
|
free(opts); |
} |
} |
|
|
static void |
static void |
|
|
if (NULL != (querystring = getenv("QUERY_STRING"))) |
if (NULL != (querystring = getenv("QUERY_STRING"))) |
http_parse(&req, querystring); |
http_parse(&req, querystring); |
|
|
if ( ! validate_manpath(&req, req.q.manpath)) { |
if ( ! (NULL == req.q.manpath || |
|
validate_manpath(&req, req.q.manpath))) { |
pg_error_badrequest( |
pg_error_badrequest( |
"You specified an invalid manpath."); |
"You specified an invalid manpath."); |
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |