diff options
Diffstat
| -rw-r--r-- | README.md | 4 | +2 −2 |
| -rw-r--r-- | cgit/cgit.c | 123 | +0 −123 |
| -rw-r--r-- | cgit/cgit.h | 36 | +2 −34 |
| -rw-r--r-- | cgit/filter.c | 186 | +11 −175 |
| -rw-r--r-- | cgit/shared.c | 5 | +0 −5 |
| -rw-r--r-- | cgit/ui-blame.c | 15 | +3 −12 |
| -rw-r--r-- | cgit/ui-commit.c | 10 | +0 −10 |
| -rw-r--r-- | cgit/ui-log.c | 2 | +0 −2 |
| -rw-r--r-- | cgit/ui-refs.c | 9 | +1 −8 |
| -rw-r--r-- | cgit/ui-repolist.c | 26 | +9 −17 |
| -rw-r--r-- | cgit/ui-shared.c | 50 | +16 −34 |
| -rw-r--r-- | cgit/ui-shared.h | 1 | +0 −1 |
| -rw-r--r-- | cgit/ui-snapshot.c | 4 | +2 −2 |
| -rw-r--r-- | cgit/ui-summary.c | 6 | +1 −5 |
| -rw-r--r-- | cgit/ui-tag.c | 2 | +0 −2 |
| -rw-r--r-- | cgit/ui-tree.c | 19 | +4 −15 |
16 files changed, 51 insertions, 447 deletions
diff --git a/README.md b/README.md index 91b7b2a..50892bf 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ platforms but aren't ready to host complex services like Forgejo. - Every configured key has read/write access to every repository and may create a repository by pushing to its name for the first time. - cgit is anonymous and read-only; every repository is publicly visible. -- Smart HTTP, password authentication, shells, forwarding, tunnels, and cgit - filters are disabled. +- Smart HTTP, password authentication, shells, forwarding, and tunnels are + disabled; cgit filters are not supported. - Gilti is a single-replica service backed by one POSIX persistent volume. It is not an HA system. diff --git a/cgit/cgit.c b/cgit/cgit.c index 0471106..6719996 100644 --- a/cgit/cgit.c +++ b/cgit/cgit.c @@ -113,18 +113,6 @@ void cgit_repo_config(struct cgit_repo *repo, const char *name, const char *valu repo->hide = atoi(value); else if (!strcmp(name, "ignore")) repo->ignore = atoi(value); - else if (ctx.cfg.enable_filter_overrides) { - if (!strcmp(name, "about-filter")) - repo->about_filter = cgit_new_filter(value, ABOUT); - else if (!strcmp(name, "commit-filter")) - repo->commit_filter = cgit_new_filter(value, COMMIT); - else if (!strcmp(name, "source-filter")) - repo->source_filter = cgit_new_filter(value, SOURCE); - else if (!strcmp(name, "email-filter")) - repo->email_filter = cgit_new_filter(value, EMAIL); - else if (!strcmp(name, "owner-filter")) - repo->owner_filter = cgit_new_filter(value, OWNER); - } } static void config_cb(const char *name, const char *value) @@ -175,8 +163,6 @@ static void config_cb(const char *name, const char *value) ctx.cfg.noheader = atoi(value); else if (!strcmp(name, "snapshots")) ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); - else if (!strcmp(name, "enable-filter-overrides")) - ctx.cfg.enable_filter_overrides = atoi(value); else if (!strcmp(name, "enable-follow-links")) ctx.cfg.enable_follow_links = atoi(value); else if (!strcmp(name, "enable-http-clone")) @@ -207,16 +193,6 @@ static void config_cb(const char *name, const char *value) ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); else if (!strcmp(name, "case-sensitive-sort")) ctx.cfg.case_sensitive_sort = atoi(value); - else if (!strcmp(name, "about-filter")) - ctx.cfg.about_filter = cgit_new_filter(value, ABOUT); - else if (!strcmp(name, "commit-filter")) - ctx.cfg.commit_filter = cgit_new_filter(value, COMMIT); - else if (!strcmp(name, "email-filter")) - ctx.cfg.email_filter = cgit_new_filter(value, EMAIL); - else if (!strcmp(name, "owner-filter")) - ctx.cfg.owner_filter = cgit_new_filter(value, OWNER); - else if (!strcmp(name, "auth-filter")) - ctx.cfg.auth_filter = cgit_new_filter(value, AUTH); else if (!strcmp(name, "embedded")) ctx.cfg.embedded = atoi(value); else if (!strcmp(name, "max-atom-items")) @@ -249,8 +225,6 @@ static void config_cb(const char *name, const char *value) ctx.cfg.repository_sort = strdup_first_line(value); else if (!strcmp(name, "section-sort")) ctx.cfg.section_sort = atoi(value); - else if (!strcmp(name, "source-filter")) - ctx.cfg.source_filter = cgit_new_filter(value, SOURCE); else if (!strcmp(name, "summary-log")) ctx.cfg.summary_log = atoi(value); else if (!strcmp(name, "summary-branches")) @@ -395,10 +369,6 @@ static void prepare_context(void) ctx.env.script_name = getenv("SCRIPT_NAME"); ctx.env.server_name = getenv("SERVER_NAME"); ctx.env.server_port = getenv("SERVER_PORT"); - ctx.env.http_cookie = getenv("HTTP_COOKIE"); - ctx.env.http_referer = getenv("HTTP_REFERER"); - ctx.env.content_length = getenv("CONTENT_LENGTH") ? strtoul(getenv("CONTENT_LENGTH"), NULL, 10) : 0; - ctx.env.authenticated = 0; ctx.page.mimetype = "text/html"; ctx.page.charset = PAGE_ENCODING; ctx.page.filename = NULL; @@ -620,87 +590,11 @@ static int prepare_repo_cmd(int nongit) return 0; } -static inline void open_auth_filter(const char *function) -{ - cgit_open_filter(ctx.cfg.auth_filter, function, - ctx.env.http_cookie ? ctx.env.http_cookie : "", - ctx.env.request_method ? ctx.env.request_method : "", - ctx.env.query_string ? ctx.env.query_string : "", - ctx.env.http_referer ? ctx.env.http_referer : "", - ctx.env.path_info ? ctx.env.path_info : "", - ctx.env.http_host ? ctx.env.http_host : "", - ctx.env.https ? ctx.env.https : "", - ctx.qry.repo ? ctx.qry.repo : "", - ctx.qry.page ? ctx.qry.page : "", - cgit_currentfullurl(), - cgit_loginurl()); -} - -/* We intentionally keep this rather small, instead of looping and - * feeding it to the filter a couple bytes at a time. This way, the - * filter itself does not need to handle any denial of service or - * buffer bloat issues. If this winds up being too small, people - * will complain on the mailing list, and we'll increase it as needed. */ -#define MAX_AUTHENTICATION_POST_BYTES 4096 -/* The filter is expected to spit out "Status: " and all headers. */ -static inline void authenticate_post(void) -{ - char buffer[MAX_AUTHENTICATION_POST_BYTES]; - ssize_t len; - - open_auth_filter("authenticate-post"); - len = ctx.env.content_length; - if (len > MAX_AUTHENTICATION_POST_BYTES) - len = MAX_AUTHENTICATION_POST_BYTES; - if ((len = read(STDIN_FILENO, buffer, len)) < 0) - die_errno("Could not read POST from stdin"); - if (write(STDOUT_FILENO, buffer, len) < 0) - die_errno("Could not write POST to stdout"); - cgit_close_filter(ctx.cfg.auth_filter); - exit(0); -} - -static inline void authenticate_cookie(void) -{ - /* If we don't have an auth_filter, consider all cookies valid, and thus return early. */ - if (!ctx.cfg.auth_filter) { - ctx.env.authenticated = 1; - return; - } - - /* If we're having something POST'd to /login, we're authenticating POST, - * instead of the cookie, so call authenticate_post and bail out early. - * This pattern here should match /?p=login with POST. */ - if (ctx.env.request_method && ctx.qry.page && !ctx.repo && \ - !strcmp(ctx.env.request_method, "POST") && !strcmp(ctx.qry.page, "login")) { - authenticate_post(); - return; - } - - /* If we've made it this far, we're authenticating the cookie for real, so do that. */ - open_auth_filter("authenticate-cookie"); - ctx.env.authenticated = cgit_close_filter(ctx.cfg.auth_filter); -} - static void process_request(void) { struct cgit_cmd *cmd; int nongit = 0; - /* If we're not yet authenticated, no matter what page we're on, - * display the authentication body from the auth_filter. This should - * never be cached. */ - if (!ctx.env.authenticated) { - ctx.page.title = "Authentication Required"; - cgit_print_http_headers(); - cgit_print_docstart(); - cgit_print_pageheader(); - open_auth_filter("body"); - cgit_close_filter(ctx.cfg.auth_filter); - cgit_print_docend(); - return; - } - if (ctx.repo) prepare_repo_env(&nongit); @@ -794,16 +688,6 @@ static void print_repo(FILE *f, struct cgit_repo *repo) repo->enable_log_filecount); fprintf(f, "repo.enable-log-linecount=%d\n", repo->enable_log_linecount); - if (repo->about_filter && repo->about_filter != ctx.cfg.about_filter) - cgit_fprintf_filter(repo->about_filter, f, "repo.about-filter="); - if (repo->commit_filter && repo->commit_filter != ctx.cfg.commit_filter) - cgit_fprintf_filter(repo->commit_filter, f, "repo.commit-filter="); - if (repo->source_filter && repo->source_filter != ctx.cfg.source_filter) - cgit_fprintf_filter(repo->source_filter, f, "repo.source-filter="); - if (repo->email_filter && repo->email_filter != ctx.cfg.email_filter) - cgit_fprintf_filter(repo->email_filter, f, "repo.email-filter="); - if (repo->owner_filter && repo->owner_filter != ctx.cfg.owner_filter) - cgit_fprintf_filter(repo->owner_filter, f, "repo.owner-filter="); if (repo->snapshots != ctx.cfg.snapshots) { char *tmp = build_snapshot_setting(repo->snapshots); fprintf(f, "repo.snapshots=%s\n", tmp ? tmp : ""); @@ -904,7 +788,6 @@ int cmd_main(int argc, const char **argv) { const char *path; - atexit(cgit_cleanup_filters); set_die_routine(cgit_die_routine); prepare_context(); @@ -942,12 +825,6 @@ int cmd_main(int argc, const char **argv) cgit_parse_url(ctx.qry.url); } - /* Before we go any further, we set ctx.env.authenticated by checking to see - * if the supplied cookie is valid. All cookies are valid if there is no - * auth_filter. If there is an auth_filter, the filter decides. */ - authenticate_cookie(); - process_request(); - cgit_cleanup_filters(); return 0; } diff --git a/cgit/cgit.h b/cgit/cgit.h index 0cbafc8..bed3f11 100644 --- a/cgit/cgit.h +++ b/cgit/cgit.h @@ -67,20 +67,7 @@ typedef enum { DIFF_UNIFIED, DIFF_SSDIFF, DIFF_STATONLY } diff_type; -typedef enum { - ABOUT, COMMIT, SOURCE, EMAIL, AUTH, OWNER -} filter_type; - -struct cgit_filter { - int (*open)(struct cgit_filter *, va_list ap); - int (*close)(struct cgit_filter *); - void (*fprintfp)(struct cgit_filter *, FILE *, const char *prefix); - void (*cleanup)(struct cgit_filter *); - int argument_count; -}; - struct cgit_exec_filter { - struct cgit_filter base; char *cmd; char **argv; int old_stdout; @@ -116,11 +103,6 @@ struct cgit_repo { int branch_sort; int commit_sort; time_t mtime; - struct cgit_filter *about_filter; - struct cgit_filter *commit_filter; - struct cgit_filter *source_filter; - struct cgit_filter *email_filter; - struct cgit_filter *owner_filter; struct string_list submodules; int hide; int ignore; @@ -223,7 +205,6 @@ struct cgit_config { char *strict_export; int case_sensitive_sort; int embedded; - int enable_filter_overrides; int enable_follow_links; int enable_http_clone; int enable_index_links; @@ -262,12 +243,6 @@ struct cgit_config { int commit_sort; struct string_list mimetypes; struct string_list js; - struct cgit_filter *about_filter; - struct cgit_filter *commit_filter; - struct cgit_filter *source_filter; - struct cgit_filter *email_filter; - struct cgit_filter *owner_filter; - struct cgit_filter *auth_filter; }; struct cgit_page { @@ -293,10 +268,6 @@ struct cgit_environment { const char *script_name; const char *server_name; const char *server_port; - const char *http_cookie; - const char *http_referer; - unsigned int content_length; - int authenticated; }; struct cgit_context { @@ -376,12 +347,9 @@ extern const struct object_id *cgit_snapshot_get_sig(const char *ref, const struct cgit_snapshot_format *f); extern const unsigned cgit_snapshot_format_bit(const struct cgit_snapshot_format *f); -extern int cgit_open_filter(struct cgit_filter *filter, ...); -extern int cgit_close_filter(struct cgit_filter *filter); -extern void cgit_fprintf_filter(struct cgit_filter *filter, FILE *f, const char *prefix); extern void cgit_exec_filter_init(struct cgit_exec_filter *filter, char *cmd, char **argv); -extern struct cgit_filter *cgit_new_filter(const char *cmd, filter_type filtertype); -extern void cgit_cleanup_filters(void); +extern int cgit_open_exec_filter(struct cgit_exec_filter *filter); +extern int cgit_close_exec_filter(struct cgit_exec_filter *filter); extern void cgit_prepare_repo_env(struct cgit_repo * repo); diff --git a/cgit/filter.c b/cgit/filter.c index de0787e..e268faf 100644 --- a/cgit/filter.c +++ b/cgit/filter.c @@ -2,7 +2,7 @@ * SPDX-License-Identifier: GPL-2.0-only */ -/* filter.c: filter framework functions +/* filter.c: executable filter used by snapshot compression * * Copyright (C) 2006-2014 cgit Development Team <cgit@lists.zx2c4.com> * @@ -12,38 +12,16 @@ #include "cgit.h" -static inline void reap_filter(struct cgit_filter *filter) -{ - if (filter && filter->cleanup) - filter->cleanup(filter); -} - -void cgit_cleanup_filters(void) +void cgit_exec_filter_init(struct cgit_exec_filter *filter, char *cmd, char **argv) { - int i; - reap_filter(ctx.cfg.about_filter); - reap_filter(ctx.cfg.commit_filter); - reap_filter(ctx.cfg.source_filter); - reap_filter(ctx.cfg.email_filter); - reap_filter(ctx.cfg.owner_filter); - reap_filter(ctx.cfg.auth_filter); - for (i = 0; i < cgit_repolist.count; ++i) { - reap_filter(cgit_repolist.repos[i].about_filter); - reap_filter(cgit_repolist.repos[i].commit_filter); - reap_filter(cgit_repolist.repos[i].source_filter); - reap_filter(cgit_repolist.repos[i].email_filter); - reap_filter(cgit_repolist.repos[i].owner_filter); - } + memset(filter, 0, sizeof(*filter)); + filter->cmd = cmd; + filter->argv = argv; } -static int open_exec_filter(struct cgit_filter *base, va_list ap) +int cgit_open_exec_filter(struct cgit_exec_filter *filter) { - struct cgit_exec_filter *filter = (struct cgit_exec_filter *)base; int pipe_fh[2]; - int i; - - for (i = 0; i < filter->base.argument_count; i++) - filter->argv[i + 1] = va_arg(ap, char *); filter->old_stdout = chk_positive(dup(STDOUT_FILENO), "Unable to duplicate STDOUT"); @@ -63,159 +41,17 @@ static int open_exec_filter(struct cgit_filter *base, va_list ap) return 0; } -static int close_exec_filter(struct cgit_filter *base) +int cgit_close_exec_filter(struct cgit_exec_filter *filter) { - struct cgit_exec_filter *filter = (struct cgit_exec_filter *)base; - int i, exit_status = 0; + int exit_status = 0; chk_non_negative(dup2(filter->old_stdout, STDOUT_FILENO), "Unable to restore STDOUT"); close(filter->old_stdout); if (filter->pid < 0) - goto done; + return WEXITSTATUS(exit_status); waitpid(filter->pid, &exit_status, 0); - if (WIFEXITED(exit_status)) - goto done; - die("Subprocess %s exited abnormally", filter->cmd); - -done: - for (i = 0; i < filter->base.argument_count; i++) - filter->argv[i + 1] = NULL; + if (!WIFEXITED(exit_status)) + die("Subprocess %s exited abnormally", filter->cmd); return WEXITSTATUS(exit_status); - -} - -static void fprintf_exec_filter(struct cgit_filter *base, FILE *f, const char *prefix) -{ - struct cgit_exec_filter *filter = (struct cgit_exec_filter *)base; - fprintf(f, "%sexec:%s\n", prefix, filter->cmd); -} - -static void cleanup_exec_filter(struct cgit_filter *base) -{ - struct cgit_exec_filter *filter = (struct cgit_exec_filter *)base; - if (filter->argv) { - free(filter->argv); - filter->argv = NULL; - } - if (filter->cmd) { - free(filter->cmd); - filter->cmd = NULL; - } -} - -static struct cgit_filter *new_exec_filter(const char *cmd, int argument_count) -{ - struct cgit_exec_filter *f; - int args_size = 0; - - f = xmalloc(sizeof(*f)); - /* We leave argv for now and assign it below. */ - cgit_exec_filter_init(f, strdup_first_line(cmd), NULL); - f->base.argument_count = argument_count; - args_size = (2 + argument_count) * sizeof(char *); - f->argv = xmalloc(args_size); - memset(f->argv, 0, args_size); - f->argv[0] = f->cmd; - return &f->base; -} - -void cgit_exec_filter_init(struct cgit_exec_filter *filter, char *cmd, char **argv) -{ - memset(filter, 0, sizeof(*filter)); - filter->base.open = open_exec_filter; - filter->base.close = close_exec_filter; - filter->base.fprintfp = fprintf_exec_filter; - filter->base.cleanup = cleanup_exec_filter; - filter->cmd = cmd; - filter->argv = argv; - /* The argument count for open_filter is zero by default, unless called from new_filter, above. */ - filter->base.argument_count = 0; -} - -int cgit_open_filter(struct cgit_filter *filter, ...) -{ - int result; - va_list ap; - if (!filter) - return 0; - va_start(ap, filter); - result = filter->open(filter, ap); - va_end(ap); - return result; -} - -int cgit_close_filter(struct cgit_filter *filter) -{ - if (!filter) - return 0; - return filter->close(filter); -} - -void cgit_fprintf_filter(struct cgit_filter *filter, FILE *f, const char *prefix) -{ - filter->fprintfp(filter, f, prefix); -} - -static const struct { - const char *prefix; - struct cgit_filter *(*ctor)(const char *cmd, int argument_count); -} filter_specs[] = { - { "exec", new_exec_filter }, -}; - -struct cgit_filter *cgit_new_filter(const char *cmd, filter_type filtertype) -{ - const char *colon; - int i; - size_t len; - int argument_count; - - if (!cmd || !cmd[0]) - return NULL; - - colon = strchr(cmd, ':'); - len = colon - cmd; - /* - * In case we're running on Windows, don't allow a single letter before - * the colon. - */ - if (len == 1) - colon = NULL; - - switch (filtertype) { - case AUTH: - argument_count = 12; - break; - - case EMAIL: - argument_count = 2; - break; - - case OWNER: - argument_count = 0; - break; - - case SOURCE: - case ABOUT: - argument_count = 1; - break; - - case COMMIT: - default: - argument_count = 0; - break; - } - - /* If no prefix is given, exec filter is the default. */ - if (!colon) - return new_exec_filter(cmd, argument_count); - - for (i = 0; i < ARRAY_SIZE(filter_specs); i++) { - if (len == strlen(filter_specs[i].prefix) && - !strncmp(filter_specs[i].prefix, cmd, len)) - return filter_specs[i].ctor(colon + 1, argument_count); - } - - die("Invalid filter type: %.*s", (int) len, cmd); } diff --git a/cgit/shared.c b/cgit/shared.c index 3222e20..e786d17 100644 --- a/cgit/shared.c +++ b/cgit/shared.c @@ -79,11 +79,6 @@ struct cgit_repo *cgit_add_repo(const char *url) ret->module_link = ctx.cfg.module_link; ret->readme = ctx.cfg.readme; ret->mtime = -1; - ret->about_filter = ctx.cfg.about_filter; - ret->commit_filter = ctx.cfg.commit_filter; - ret->source_filter = ctx.cfg.source_filter; - ret->email_filter = ctx.cfg.email_filter; - ret->owner_filter = ctx.cfg.owner_filter; ret->clone_url = ctx.cfg.clone_url; ret->submodules.strdup_strings = 1; ret->hide = ret->ignore = 0; diff --git a/cgit/ui-blame.c b/cgit/ui-blame.c index c56b50e..e714256 100644 --- a/cgit/ui-blame.c +++ b/cgit/ui-blame.c @@ -114,7 +114,7 @@ struct walk_tree_context { }; static void print_object(const struct object_id *oid, const char *path, - const char *basename, const char *rev) + const char *rev) { enum object_type type; char *buf; @@ -218,15 +218,7 @@ static void print_object(const struct object_id *oid, const char *path, /* Lines */ html("<pre><code>"); - if (ctx.repo->source_filter) { - char *filter_arg = xstrdup(basename); - cgit_open_filter(ctx.repo->source_filter, filter_arg); - html_raw(buf, size); - cgit_close_filter(ctx.repo->source_filter); - free(filter_arg); - } else { - html_txt(buf); - } + html_txt(buf); html("</code></pre>"); html("</div></td>\n"); @@ -249,8 +241,7 @@ static int walk_tree(const struct object_id *oid, struct strbuf *base, struct strbuf buffer = STRBUF_INIT; strbuf_addbuf(&buffer, base); strbuf_addstr(&buffer, pathname); - print_object(oid, buffer.buf, pathname, - walk_tree_ctx->curr_rev); + print_object(oid, buffer.buf, walk_tree_ctx->curr_rev); strbuf_release(&buffer); walk_tree_ctx->state = 1; } else if (S_ISDIR(mode)) { diff --git a/cgit/ui-commit.c b/cgit/ui-commit.c index afd97c9..92953ee 100644 --- a/cgit/ui-commit.c +++ b/cgit/ui-commit.c @@ -54,25 +54,21 @@ void cgit_print_commit(char *hex, const char *prefix) cgit_print_diff_ctrls(); html("<table summary='commit info' class='commit-info'>\n"); html("<tr><th>author</th><td>"); - cgit_open_filter(ctx.repo->email_filter, info->author_email, "commit"); html_txt(info->author); if (!ctx.cfg.noplainemail) { html(" "); html_txt(info->author_email); } - cgit_close_filter(ctx.repo->email_filter); html("</td><td class='right'>"); html_txt(show_date(info->author_date, info->author_tz, cgit_date_mode(DATE_ISO8601))); html("</td></tr>\n"); html("<tr><th>committer</th><td>"); - cgit_open_filter(ctx.repo->email_filter, info->committer_email, "commit"); html_txt(info->committer); if (!ctx.cfg.noplainemail) { html(" "); html_txt(info->committer_email); } - cgit_close_filter(ctx.repo->email_filter); html("</td><td class='right'>"); html_txt(show_date(info->committer_date, info->committer_tz, cgit_date_mode(DATE_ISO8601))); @@ -122,22 +118,16 @@ void cgit_print_commit(char *hex, const char *prefix) } html("</table>\n"); html("<div class='commit-subject'>"); - cgit_open_filter(ctx.repo->commit_filter); html_txt(info->subject); - cgit_close_filter(ctx.repo->commit_filter); show_commit_decorations(commit); html("</div>"); html("<div class='commit-msg'>"); - cgit_open_filter(ctx.repo->commit_filter); html_txt(info->msg); - cgit_close_filter(ctx.repo->commit_filter); html("</div>"); if (notes.len != 0) { html("<div class='notes-header'>Notes</div>"); html("<div class='notes'>"); - cgit_open_filter(ctx.repo->commit_filter); html_txt(notes.buf); - cgit_close_filter(ctx.repo->commit_filter); html("</div>"); html("<div class='notes-footer'></div>"); } diff --git a/cgit/ui-log.c b/cgit/ui-log.c index e7a5413..2087f75 100644 --- a/cgit/ui-log.c +++ b/cgit/ui-log.c @@ -250,9 +250,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs) oid_to_hex(&commit->object.oid), ctx.qry.vpath); show_commit_decorations(commit); html("</td><td>"); - cgit_open_filter(ctx.repo->email_filter, info->author_email, "log"); html_txt(info->author); - cgit_close_filter(ctx.repo->email_filter); if (revs->graph) { html("</td><td>"); diff --git a/cgit/ui-refs.c b/cgit/ui-refs.c index 25f1600..1cd53f8 100644 --- a/cgit/ui-refs.c +++ b/cgit/ui-refs.c @@ -75,9 +75,7 @@ static int print_branch(struct refinfo *ref) if (ref->object->type == OBJ_COMMIT) { cgit_commit_link(info->subject, NULL, NULL, name, NULL, NULL); html("</td><td>"); - cgit_open_filter(ctx.repo->email_filter, info->author_email, "refs"); html_txt(info->author); - cgit_close_filter(ctx.repo->email_filter); html("</td><td colspan='2'>"); cgit_print_age(info->committer_date, info->committer_tz, -1); } else { @@ -120,15 +118,10 @@ static int print_tag(struct refinfo *ref) cgit_object_link(obj); html("</td><td>"); if (info) { - if (info->tagger) { - cgit_open_filter(ctx.repo->email_filter, info->tagger_email, "refs"); + if (info->tagger) html_txt(info->tagger); - cgit_close_filter(ctx.repo->email_filter); - } } else if (ref->object->type == OBJ_COMMIT) { - cgit_open_filter(ctx.repo->email_filter, ref->commit->author_email, "refs"); html_txt(ref->commit->author); - cgit_close_filter(ctx.repo->email_filter); } html("</td><td colspan='2'>"); if (info) { diff --git a/cgit/ui-repolist.c b/cgit/ui-repolist.c index a0974f3..faf3f5f 100644 --- a/cgit/ui-repolist.c +++ b/cgit/ui-repolist.c @@ -335,21 +335,15 @@ void cgit_print_repolist(void) html_link_close(); html("</td><td>"); if (ctx.cfg.enable_index_owner) { - if (ctx.repo->owner_filter) { - cgit_open_filter(ctx.repo->owner_filter); - html_txt(ctx.repo->owner); - cgit_close_filter(ctx.repo->owner_filter); - } else { - char *currenturl = cgit_currenturl(); - html("<a href='"); - html_attr(currenturl); - html("?q="); - html_url_arg(ctx.repo->owner); - html("'>"); - html_txt(ctx.repo->owner); - html("</a>"); - free(currenturl); - } + char *currenturl = cgit_currenturl(); + html("<a href='"); + html_attr(currenturl); + html("?q="); + html_url_arg(ctx.repo->owner); + html("'>"); + html_txt(ctx.repo->owner); + html("</a>"); + free(currenturl); html("</td><td>"); } print_modtime(ctx.repo); @@ -375,9 +369,7 @@ void cgit_print_site_readme(void) cgit_print_layout_start(); if (!ctx.cfg.root_readme) goto done; - cgit_open_filter(ctx.cfg.about_filter, ctx.cfg.root_readme); html_include(ctx.cfg.root_readme); - cgit_close_filter(ctx.cfg.about_filter); done: cgit_print_layout_end(); } diff --git a/cgit/ui-shared.c b/cgit/ui-shared.c index 976f55b..d5e9a5f 100644 --- a/cgit/ui-shared.c +++ b/cgit/ui-shared.c @@ -126,14 +126,6 @@ const char *cgit_rooturl(void) return ctx.cfg.script_name; } -const char *cgit_loginurl(void) -{ - static const char *login_url; - if (!login_url) - login_url = fmtalloc("%s?p=login", cgit_rooturl()); - return login_url; -} - char *cgit_repourl(const char *reponame) { if (ctx.cfg.virtual_root) @@ -747,8 +739,6 @@ void cgit_print_http_headers(void) html_header_arg_in_quotes(ctx.page.filename); html("\"\n"); } - if (!ctx.env.authenticated) - html("Cache-Control: no-cache, no-store\n"); htmlf("Last-Modified: %s\n", http_date(ctx.page.modified)); if (ctx.page.etag) htmlf("ETag: \"%s\"\n", ctx.page.etag); @@ -1045,20 +1035,18 @@ static void print_header(void) cgit_index_link("index", NULL, NULL, NULL, NULL, 0, 1); html(" : "); cgit_summary_link(ctx.repo->name, NULL, NULL, NULL); - if (ctx.env.authenticated) { - html("</td><td class='form'>"); - html("<form method='get'>\n"); - cgit_add_hidden_formfields(0, 1, ctx.qry.page); - html("<select name='h' onchange='this.form.submit();'>\n"); - refs_for_each_branch_ref(get_main_ref_store(the_repository), + html("</td><td class='form'>"); + html("<form method='get'>\n"); + cgit_add_hidden_formfields(0, 1, ctx.qry.page); + html("<select name='h' onchange='this.form.submit();'>\n"); + refs_for_each_branch_ref(get_main_ref_store(the_repository), + print_branch_option, ctx.qry.head); + if (ctx.repo->enable_remote_branches) + refs_for_each_remote_ref(get_main_ref_store(the_repository), print_branch_option, ctx.qry.head); - if (ctx.repo->enable_remote_branches) - refs_for_each_remote_ref(get_main_ref_store(the_repository), - print_branch_option, ctx.qry.head); - html("</select> "); - html("<input type='submit' value='switch'/>"); - html("</form>"); - } + html("</select> "); + html("<input type='submit' value='switch'/>"); + html("</form>"); } else html_txt(ctx.cfg.root_title); html("</td></tr>\n"); @@ -1067,13 +1055,7 @@ static void print_header(void) if (ctx.repo) { html_txt(ctx.repo->desc); html("</td><td class='sub right'>"); - if (ctx.repo->owner_filter) { - cgit_open_filter(ctx.repo->owner_filter); - html_txt(ctx.repo->owner); - cgit_close_filter(ctx.repo->owner_filter); - } else { - html_txt(ctx.repo->owner); - } + html_txt(ctx.repo->owner); } else { if (ctx.cfg.root_desc) html_txt(ctx.cfg.root_desc); @@ -1084,11 +1066,11 @@ static void print_header(void) void cgit_print_pageheader(void) { html("<div id='cgit'>"); - if (!ctx.env.authenticated || !ctx.cfg.noheader) + if (!ctx.cfg.noheader) print_header(); html("<table class='tabs'><tr><td>\n"); - if (ctx.env.authenticated && ctx.repo) { + if (ctx.repo) { if (ctx.repo->readme.nr) reporevlink("about", "about", NULL, hc("about"), ctx.qry.head, NULL, @@ -1139,7 +1121,7 @@ void cgit_print_pageheader(void) html("'/>\n"); html("<input type='submit' value='search'/>\n"); html("</form>\n"); - } else if (ctx.env.authenticated) { + } else { char *currenturl = cgit_currenturl(); site_link(NULL, "index", NULL, hc("repolist"), NULL, NULL, 0, 1); if (ctx.cfg.root_readme) @@ -1157,7 +1139,7 @@ void cgit_print_pageheader(void) free(currenturl); } html("</td></tr></table>\n"); - if (ctx.env.authenticated && ctx.repo && ctx.qry.vpath) { + if (ctx.repo && ctx.qry.vpath) { html("<div class='path'>"); html("path: "); cgit_print_path_crumbs(ctx.qry.vpath); diff --git a/cgit/ui-shared.h b/cgit/ui-shared.h index 8fabef0..9e0027c 100644 --- a/cgit/ui-shared.h +++ b/cgit/ui-shared.h @@ -10,7 +10,6 @@ extern char *cgit_hosturl(void); extern const char *cgit_rooturl(void); extern char *cgit_currenturl(void); extern char *cgit_currentfullurl(void); -extern const char *cgit_loginurl(void); extern char *cgit_repourl(const char *reponame); extern char *cgit_fileurl(const char *reponame, const char *pagename, const char *filename, const char *query); diff --git a/cgit/ui-snapshot.c b/cgit/ui-snapshot.c index 5593ba6..99fae75 100644 --- a/cgit/ui-snapshot.c +++ b/cgit/ui-snapshot.c @@ -67,9 +67,9 @@ static int write_compressed_tar_archive(const char *hex, struct cgit_exec_filter f; cgit_exec_filter_init(&f, filter_argv[0], filter_argv); - cgit_open_filter(&f.base); + cgit_open_exec_filter(&f); rv = write_tar_archive(hex, prefix); - cgit_close_filter(&f.base); + cgit_close_exec_filter(&f); return rv; } diff --git a/cgit/ui-summary.c b/cgit/ui-summary.c index a69b8cb..31567ec 100644 --- a/cgit/ui-summary.c +++ b/cgit/ui-summary.c @@ -132,16 +132,12 @@ void cgit_print_repo_readme(const char *path) goto done; } - /* Print the calculated readme, either from the git repo or from the - * filesystem, while applying the about-filter. - */ + /* Print the calculated readme from the git repo or filesystem. */ html("<div id='summary'>"); - cgit_open_filter(ctx.repo->about_filter, filename); if (ref) cgit_print_file(filename, ref, 1); else html_include(filename); - cgit_close_filter(ctx.repo->about_filter); html("</div>"); if (free_filename) diff --git a/cgit/ui-tag.c b/cgit/ui-tag.c index b8acbb7..86b81bd 100644 --- a/cgit/ui-tag.c +++ b/cgit/ui-tag.c @@ -88,13 +88,11 @@ void cgit_print_tag(char *revname) } if (info->tagger) { html("<tr><td>tagged by</td><td>"); - cgit_open_filter(ctx.repo->email_filter, info->tagger_email, "tag"); html_txt(info->tagger); if (info->tagger_email && !ctx.cfg.noplainemail) { html(" "); html_txt(info->tagger_email); } - cgit_close_filter(ctx.repo->email_filter); html("</td></tr>\n"); } html("<tr><td>tagged object</td><td class='oid'>"); diff --git a/cgit/ui-tree.c b/cgit/ui-tree.c index 71168a0..1ef9508 100644 --- a/cgit/ui-tree.c +++ b/cgit/ui-tree.c @@ -23,7 +23,7 @@ struct walk_tree_context { int state; }; -static void print_text_buffer(const char *name, char *buf, unsigned long size) +static void print_text_buffer(char *buf, unsigned long size) { unsigned long lineno, idx; const char *numberfmt = "<a id='n%1$d' href='#n%1$d'>%1$d</a>\n"; @@ -49,17 +49,6 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) html("<tr>\n"); } - if (ctx.repo->source_filter) { - char *filter_arg = xstrdup(name); - html("<td class='lines'><pre><code>"); - cgit_open_filter(ctx.repo->source_filter, filter_arg); - html_raw(buf, size); - cgit_close_filter(ctx.repo->source_filter); - free(filter_arg); - html("</code></pre></td></tr></table>\n"); - return; - } - html("<td class='lines'><pre><code>"); html_txt(buf); html("</code></pre></td></tr></table>\n"); @@ -90,7 +79,7 @@ static void print_binary_buffer(char *buf, unsigned long size) html("</table>\n"); } -static void print_object(const struct object_id *oid, const char *path, const char *basename, const char *rev) +static void print_object(const struct object_id *oid, const char *path, const char *rev) { enum object_type type; char *buf; @@ -134,7 +123,7 @@ static void print_object(const struct object_id *oid, const char *path, const ch if (is_binary) print_binary_buffer(buf, size); else - print_text_buffer(basename, buf, size); + print_text_buffer(buf, size); free(buf); } @@ -344,7 +333,7 @@ static int walk_tree(const struct object_id *oid, struct strbuf *base, return READ_TREE_RECURSIVE; } else { walk_tree_ctx->state = 2; - print_object(oid, buffer.buf, pathname, walk_tree_ctx->curr_rev); + print_object(oid, buffer.buf, walk_tree_ctx->curr_rev); strbuf_release(&buffer); return 0; } |
