diff options
author | Jason A. Donenfeld | 2019-05-20 21:45:12 +0200 |
---|---|---|
committer | Jason A. Donenfeld | 2019-05-20 21:53:16 +0200 |
commit | 54c407a74a35d4ee9ffae94cc5bc9096c9f7f54a (patch) | |
tree | 2bb3e863ea5ceb8f06e541b62a17bef305adbfd9 | |
parent | bd0293f57015ede637b630fcaf4fc11e7697d777 (diff) | |
download | cgit-54c407a74a35d4ee9ffae94cc5bc9096c9f7f54a.tar.gz cgit-54c407a74a35d4ee9ffae94cc5bc9096c9f7f54a.tar.bz2 cgit-54c407a74a35d4ee9ffae94cc5bc9096c9f7f54a.zip |
ui-shared: restrict to 15 levels
Perhaps a more ideal version of this would be to not print breadcrumbs
at all for paths that don't exist in the given repo at the given oid.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reported-by: Fydor Wire Snark <wsnark@tuta.io>
-rw-r--r-- | ui-shared.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ui-shared.c b/ui-shared.c index d27a5fd..d2358f2 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -945,12 +945,13 @@ static void cgit_print_path_crumbs(char *path) | |||
945 | { | 945 | { |
946 | char *old_path = ctx.qry.path; | 946 | char *old_path = ctx.qry.path; |
947 | char *p = path, *q, *end = path + strlen(path); | 947 | char *p = path, *q, *end = path + strlen(path); |
948 | int levels = 0; | ||
948 | 949 | ||
949 | ctx.qry.path = NULL; | 950 | ctx.qry.path = NULL; |
950 | cgit_self_link("root", NULL, NULL); | 951 | cgit_self_link("root", NULL, NULL); |
951 | ctx.qry.path = p = path; | 952 | ctx.qry.path = p = path; |
952 | while (p < end) { | 953 | while (p < end) { |
953 | if (!(q = strchr(p, '/'))) | 954 | if (!(q = strchr(p, '/')) || levels > 15) |
954 | q = end; | 955 | q = end; |
955 | *q = '\0'; | 956 | *q = '\0'; |
956 | html_txt("/"); | 957 | html_txt("/"); |
@@ -958,6 +959,7 @@ static void cgit_print_path_crumbs(char *path) | |||
958 | if (q < end) | 959 | if (q < end) |
959 | *q = '/'; | 960 | *q = '/'; |
960 | p = q + 1; | 961 | p = q + 1; |
962 | ++levels; | ||
961 | } | 963 | } |
962 | ctx.qry.path = old_path; | 964 | ctx.qry.path = old_path; |
963 | } | 965 | } |