]> git.cameronkatri.com Git - cgit.git/commitdiff
ui-shared: restrict to 15 levels
authorJason A. Donenfeld <Jason@zx2c4.com>
Mon, 20 May 2019 19:45:12 +0000 (21:45 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Mon, 20 May 2019 19:53:16 +0000 (21:53 +0200)
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>
ui-shared.c

index d27a5fd972c282272029c125877ef1ae1b2de07e..d2358f292823ce11bfe91523ed833cdf4cdca235 100644 (file)
@@ -945,12 +945,13 @@ static void cgit_print_path_crumbs(char *path)
 {
        char *old_path = ctx.qry.path;
        char *p = path, *q, *end = path + strlen(path);
+       int levels = 0;
 
        ctx.qry.path = NULL;
        cgit_self_link("root", NULL, NULL);
        ctx.qry.path = p = path;
        while (p < end) {
-               if (!(q = strchr(p, '/')))
+               if (!(q = strchr(p, '/')) || levels > 15)
                        q = end;
                *q = '\0';
                html_txt("/");
@@ -958,6 +959,7 @@ static void cgit_print_path_crumbs(char *path)
                if (q < end)
                        *q = '/';
                p = q + 1;
+               ++levels;
        }
        ctx.qry.path = old_path;
 }