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) (unidiff) | |
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
@@ -129,4 +129,20 @@ void html_attr(char *txt) | |||
129 | } | 129 | } |
130 | 130 | ||
131 | void html_url_path(char *txt) | ||
132 | { | ||
133 | char *t = txt; | ||
134 | while(t && *t){ | ||
135 | int c = *t; | ||
136 | if (c=='"' || c=='#' || c=='\'' || c=='?') { | ||
137 | write(htmlfd, txt, t - txt); | ||
138 | write(htmlfd, fmt("%%%2x", c), 3); | ||
139 | txt = t+1; | ||
140 | } | ||
141 | t++; | ||
142 | } | ||
143 | if (t!=txt) | ||
144 | html(txt); | ||
145 | } | ||
146 | |||
131 | void html_url_arg(char *txt) | 147 | void html_url_arg(char *txt) |
132 | { | 148 | { |
@@ -11,4 +11,5 @@ extern void html_txt(char *txt); | |||
11 | extern void html_ntxt(int len, char *txt); | 11 | extern void html_ntxt(int len, char *txt); |
12 | extern void html_attr(char *txt); | 12 | extern void html_attr(char *txt); |
13 | extern void html_url_path(char *txt); | ||
13 | extern void html_url_arg(char *txt); | 14 | extern void html_url_arg(char *txt); |
14 | extern void html_hidden(char *name, char *value); | 15 | extern void html_hidden(char *name, char *value); |
diff --git a/ui-repolist.c b/ui-repolist.c index 725338b..ab050c7 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -132,7 +132,5 @@ void cgit_print_repolist() | |||
132 | htmlf("<tr><td class='%s'>", | 132 | htmlf("<tr><td class='%s'>", |
133 | ctx.repo->group ? "sublevel-repo" : "toplevel-repo"); | 133 | ctx.repo->group ? "sublevel-repo" : "toplevel-repo"); |
134 | html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL); | 134 | cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL); |
135 | html_txt(ctx.repo->name); | ||
136 | html_link_close(); | ||
137 | html("</td><td>"); | 135 | html("</td><td>"); |
138 | html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL); | 136 | html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL); |
@@ -146,7 +144,5 @@ void cgit_print_repolist() | |||
146 | if (ctx.cfg.enable_index_links) { | 144 | if (ctx.cfg.enable_index_links) { |
147 | html("<td>"); | 145 | html("<td>"); |
148 | html_link_open(cgit_repourl(ctx.repo->url), | 146 | cgit_summary_link("summary", NULL, "button", NULL); |
149 | NULL, "button"); | ||
150 | html("summary</a>"); | ||
151 | cgit_log_link("log", NULL, "button", NULL, NULL, NULL, | 147 | cgit_log_link("log", NULL, "button", NULL, NULL, NULL, |
152 | 0, NULL, NULL); | 148 | 0, NULL, NULL); |
diff --git a/ui-shared.c b/ui-shared.c index a2f636c..1fc5c09 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -207,15 +207,15 @@ static char *repolink(char *title, char *class, char *page, char *head, | |||
207 | html(" href='"); | 207 | html(" href='"); |
208 | if (ctx.cfg.virtual_root) { | 208 | if (ctx.cfg.virtual_root) { |
209 | html_attr(ctx.cfg.virtual_root); | 209 | html_url_path(ctx.cfg.virtual_root); |
210 | if (ctx.cfg.virtual_root[strlen(ctx.cfg.virtual_root) - 1] != '/') | 210 | if (ctx.cfg.virtual_root[strlen(ctx.cfg.virtual_root) - 1] != '/') |
211 | html("/"); | 211 | html("/"); |
212 | html_attr(ctx.repo->url); | 212 | html_url_path(ctx.repo->url); |
213 | if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') | 213 | if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') |
214 | html("/"); | 214 | html("/"); |
215 | if (page) { | 215 | if (page) { |
216 | html(page); | 216 | html_url_path(page); |
217 | html("/"); | 217 | html("/"); |
218 | if (path) | 218 | if (path) |
219 | html_attr(path); | 219 | html_url_path(path); |
220 | } | 220 | } |
221 | } else { | 221 | } else { |
@@ -258,4 +258,9 @@ static void reporevlink(char *page, char *name, char *title, char *class, | |||
258 | } | 258 | } |
259 | 259 | ||
260 | void cgit_summary_link(char *name, char *title, char *class, char *head) | ||
261 | { | ||
262 | reporevlink(NULL, name, title, class, head, NULL, NULL); | ||
263 | } | ||
264 | |||
260 | void cgit_tree_link(char *name, char *title, char *class, char *head, | 265 | void cgit_tree_link(char *name, char *title, char *class, char *head, |
261 | char *rev, char *path) | 266 | char *rev, char *path) |
@@ -599,6 +604,5 @@ void cgit_print_pageheader(struct cgit_context *ctx) | |||
599 | cgit_index_link("index", NULL, NULL, NULL, 0); | 604 | cgit_index_link("index", NULL, NULL, NULL, 0); |
600 | html(" : "); | 605 | html(" : "); |
601 | reporevlink(NULL, ctx->repo->name, NULL, hc(cmd, "summary"), | 606 | cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL); |
602 | ctx->qry.head, NULL, NULL); | ||
603 | html("</td><td class='form'>"); | 607 | html("</td><td class='form'>"); |
604 | html("<form method='get' action=''>\n"); | 608 | html("<form method='get' action=''>\n"); |
@@ -628,6 +632,6 @@ void cgit_print_pageheader(struct cgit_context *ctx) | |||
628 | html("<table class='tabs'><tr><td>\n"); | 632 | html("<table class='tabs'><tr><td>\n"); |
629 | if (ctx->repo) { | 633 | if (ctx->repo) { |
630 | reporevlink(NULL, "summary", NULL, hc(cmd, "summary"), | 634 | cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, |
631 | ctx->qry.head, NULL, NULL); | 635 | ctx->qry.head); |
632 | cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, | 636 | cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, |
633 | ctx->qry.sha1, NULL); | 637 | ctx->qry.sha1, NULL); |
diff --git a/ui-shared.h b/ui-shared.h index 747f092..0cd5ed1 100644 --- a/ui-shared.h +++ b/ui-shared.h | |||
@@ -11,4 +11,5 @@ extern char *cgit_pageurl(const char *reponame, const char *pagename, | |||
11 | extern void cgit_index_link(char *name, char *title, char *class, | 11 | extern void cgit_index_link(char *name, char *title, char *class, |
12 | char *pattern, int ofs); | 12 | char *pattern, int ofs); |
13 | extern void cgit_summary_link(char *name, char *title, char *class, char *head); | ||
13 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, | 14 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, |
14 | char *rev, char *path); | 15 | char *rev, char *path); |