author | Lars Hjemli <hjemli@gmail.com> | 2008-10-05 15:16:48 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-10-05 15:16:48 (UTC) |
commit | c6bea0375aa7898ea3229483741944303740801e (patch) (side-by-side diff) | |
tree | 249000a4b85dbab2a7067042f9d835bc0a5e5f8f | |
parent | 20c895f6889a66d7cf43c67a7c22df6ef324ed5d (diff) | |
parent | 49ecbbddf0659c6409befcfe8989f92196133cda (diff) | |
download | cgit-c6bea0375aa7898ea3229483741944303740801e.zip cgit-c6bea0375aa7898ea3229483741944303740801e.tar.gz cgit-c6bea0375aa7898ea3229483741944303740801e.tar.bz2 |
Merge branch 'lh/escape-urls'
* lh/escape-urls:
ui-repolist + ui-shared: Use cgit_summary_link()
ui-shared.c: add cgit_summary_link()
ui-shared.c: use html_url_path() in repolink()
html.c: add html_url_path
-rw-r--r-- | html.c | 16 | ||||
-rw-r--r-- | html.h | 1 | ||||
-rw-r--r-- | ui-repolist.c | 8 | ||||
-rw-r--r-- | ui-shared.c | 20 | ||||
-rw-r--r-- | ui-shared.h | 1 |
5 files changed, 32 insertions, 14 deletions
@@ -127,8 +127,24 @@ void html_attr(char *txt) if (t!=txt) html(txt); } +void html_url_path(char *txt) +{ + char *t = txt; + while(t && *t){ + int c = *t; + if (c=='"' || c=='#' || c=='\'' || c=='?') { + write(htmlfd, txt, t - txt); + write(htmlfd, fmt("%%%2x", c), 3); + txt = t+1; + } + t++; + } + if (t!=txt) + html(txt); +} + void html_url_arg(char *txt) { char *t = txt; while(t && *t){ @@ -9,8 +9,9 @@ extern void htmlf(const char *format,...); extern void html_status(int code, const char *msg, int more_headers); extern void html_txt(char *txt); extern void html_ntxt(int len, char *txt); extern void html_attr(char *txt); +extern void html_url_path(char *txt); extern void html_url_arg(char *txt); extern void html_hidden(char *name, char *value); extern void html_option(char *value, char *text, char *selected_value); extern void html_link_open(char *url, char *title, char *class); diff --git a/ui-repolist.c b/ui-repolist.c index 725338b..ab050c7 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -130,11 +130,9 @@ void cgit_print_repolist() last_group = ctx.repo->group; } htmlf("<tr><td class='%s'>", ctx.repo->group ? "sublevel-repo" : "toplevel-repo"); - html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL); - html_txt(ctx.repo->name); - html_link_close(); + cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL); html("</td><td>"); html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL); html_ntxt(ctx.cfg.max_repodesc_len, ctx.repo->desc); html_link_close(); @@ -144,11 +142,9 @@ void cgit_print_repolist() print_modtime(ctx.repo); html("</td>"); if (ctx.cfg.enable_index_links) { html("<td>"); - html_link_open(cgit_repourl(ctx.repo->url), - NULL, "button"); - html("summary</a>"); + cgit_summary_link("summary", NULL, "button", NULL); cgit_log_link("log", NULL, "button", NULL, NULL, NULL, 0, NULL, NULL); cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL); html("</td>"); diff --git a/ui-shared.c b/ui-shared.c index a2f636c..1fc5c09 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -205,19 +205,19 @@ static char *repolink(char *title, char *class, char *page, char *head, html("'"); } html(" href='"); if (ctx.cfg.virtual_root) { - html_attr(ctx.cfg.virtual_root); + html_url_path(ctx.cfg.virtual_root); if (ctx.cfg.virtual_root[strlen(ctx.cfg.virtual_root) - 1] != '/') html("/"); - html_attr(ctx.repo->url); + html_url_path(ctx.repo->url); if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') html("/"); if (page) { - html(page); + html_url_path(page); html("/"); if (path) - html_attr(path); + html_url_path(path); } } else { html(ctx.cfg.script_name); html("?url="); @@ -256,8 +256,13 @@ static void reporevlink(char *page, char *name, char *title, char *class, html_txt(name); html("</a>"); } +void cgit_summary_link(char *name, char *title, char *class, char *head) +{ + reporevlink(NULL, name, title, class, head, NULL, NULL); +} + void cgit_tree_link(char *name, char *title, char *class, char *head, char *rev, char *path) { reporevlink("tree", name, title, class, head, rev, path); @@ -597,10 +602,9 @@ void cgit_print_pageheader(struct cgit_context *ctx) html("<td class='main'>"); if (ctx->repo) { cgit_index_link("index", NULL, NULL, NULL, 0); html(" : "); - reporevlink(NULL, ctx->repo->name, NULL, hc(cmd, "summary"), - ctx->qry.head, NULL, NULL); + cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL); html("</td><td class='form'>"); html("<form method='get' action=''>\n"); add_hidden_formfields(0, 1, ctx->qry.page); html("<select name='h' onchange='this.form.submit();'>\n"); @@ -626,10 +630,10 @@ void cgit_print_pageheader(struct cgit_context *ctx) html("</td></tr></table>\n"); html("<table class='tabs'><tr><td>\n"); if (ctx->repo) { - reporevlink(NULL, "summary", NULL, hc(cmd, "summary"), - ctx->qry.head, NULL, NULL); + cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, + ctx->qry.head); cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, ctx->qry.sha1, NULL); cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head, NULL, NULL, 0, NULL, NULL); diff --git a/ui-shared.h b/ui-shared.h index 747f092..0cd5ed1 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -9,8 +9,9 @@ extern char *cgit_pageurl(const char *reponame, const char *pagename, const char *query); extern void cgit_index_link(char *name, char *title, char *class, char *pattern, int ofs); +extern void cgit_summary_link(char *name, char *title, char *class, char *head); extern void cgit_tree_link(char *name, char *title, char *class, char *head, char *rev, char *path); extern void cgit_plain_link(char *name, char *title, char *class, char *head, char *rev, char *path); |