aboutsummaryrefslogtreecommitdiffstats
path: root/cgit.c
diff options
context:
space:
mode:
Diffstat (limited to 'cgit.c')
-rw-r--r--cgit.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/cgit.c b/cgit.c
index 57e11cd..608cab6 100644
--- a/cgit.c
+++ b/cgit.c
@@ -159,6 +159,10 @@ static void querystring_cb(const char *name, const char *value)
159 ctx.qry.name = xstrdup(value); 159 ctx.qry.name = xstrdup(value);
160 } else if (!strcmp(name, "mimetype")) { 160 } else if (!strcmp(name, "mimetype")) {
161 ctx.qry.mimetype = xstrdup(value); 161 ctx.qry.mimetype = xstrdup(value);
162 } else if (!strcmp(name, "s")){
163 ctx.qry.sort = xstrdup(value);
164 } else if (!strcmp(name, "showmsg")) {
165 ctx.qry.showmsg = atoi(value);
162 } else if (!strcmp(name, "period")) { 166 } else if (!strcmp(name, "period")) {
163 ctx.qry.period = xstrdup(value); 167 ctx.qry.period = xstrdup(value);
164 } 168 }
@@ -297,7 +301,6 @@ static void process_request(void *cbdata)
297 cmd = cgit_get_cmd(ctx); 301 cmd = cgit_get_cmd(ctx);
298 if (!cmd) { 302 if (!cmd) {
299 ctx->page.title = "cgit error"; 303 ctx->page.title = "cgit error";
300 ctx->repo = NULL;
301 cgit_print_http_headers(ctx); 304 cgit_print_http_headers(ctx);
302 cgit_print_docstart(ctx); 305 cgit_print_docstart(ctx);
303 cgit_print_pageheader(ctx); 306 cgit_print_pageheader(ctx);
@@ -443,28 +446,29 @@ int main(int argc, const char **argv)
443 ctx.repo = NULL; 446 ctx.repo = NULL;
444 http_parse_querystring(ctx.qry.raw, querystring_cb); 447 http_parse_querystring(ctx.qry.raw, querystring_cb);
445 448
446 /* If virtual-root isn't specified in cgitrc and no url 449 /* If virtual-root isn't specified in cgitrc, lets pretend
447 * parameter is specified on the querystring, lets pretend 450 * that virtual-root equals SCRIPT_NAME.
448 * that virtualroot equals SCRIPT_NAME and use PATH_INFO as
449 * url. This allows cgit to work with virtual urls without
450 * the need for rewriterules in the webserver (as long as
451 * PATH_INFO is included in the cache lookup key).
452 */ 451 */
453 if (!ctx.cfg.virtual_root && !ctx.qry.url) { 452 if (!ctx.cfg.virtual_root)
454 ctx.cfg.virtual_root = ctx.cfg.script_name; 453 ctx.cfg.virtual_root = ctx.cfg.script_name;
455 path = getenv("PATH_INFO"); 454
456 if (path) { 455 /* If no url parameter is specified on the querystring, lets
457 if (path[0] == '/') 456 * use PATH_INFO as url. This allows cgit to work with virtual
458 path++; 457 * urls without the need for rewriterules in the webserver (as
459 ctx.qry.url = xstrdup(path); 458 * long as PATH_INFO is included in the cache lookup key).
460 if (ctx.qry.raw) { 459 */
461 qry = ctx.qry.raw; 460 path = getenv("PATH_INFO");
462 ctx.qry.raw = xstrdup(fmt("%s?%s", path, qry)); 461 if (!ctx.qry.url && path) {
463 free(qry); 462 if (path[0] == '/')
464 } else 463 path++;
465 ctx.qry.raw = ctx.qry.url; 464 ctx.qry.url = xstrdup(path);
466 cgit_parse_url(ctx.qry.url); 465 if (ctx.qry.raw) {
467 } 466 qry = ctx.qry.raw;
467 ctx.qry.raw = xstrdup(fmt("%s?%s", path, qry));
468 free(qry);
469 } else
470 ctx.qry.raw = ctx.qry.url;
471 cgit_parse_url(ctx.qry.url);
468 } 472 }
469 473
470 ttl = calc_ttl(); 474 ttl = calc_ttl();