diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Harden the page renderers
Diffstat (limited to 'source/ui-tag.c')
-rw-r--r--source/ui-tag.c15
1 file changed, 13 insertions, 2 deletions
diff --git a/source/ui-tag.c b/source/ui-tag.c
index 56862bb..6811e0c 100644
--- a/source/ui-tag.c
+++ b/source/ui-tag.c
@@ -131,6 +131,16 @@ static void print_lightweight_tag(const char *revname, struct object *obj)
cgit_print_layout_end();
}
+/*
+ * A tag pointing at another tag links the inner one by object id, since no ref
+ * names it.
+ */
+static int tag_by_id(const char *name, struct object_id *oid)
+{
+ return !get_oid_hex(name, oid) &&
+ odb_read_object_info(the_repository->objects, oid, NULL) == OBJ_TAG;
+}
+
void cgit_print_tag(char *revname)
{
struct strbuf fullref = STRBUF_INIT;
@@ -141,13 +151,14 @@ void cgit_print_tag(char *revname)
revname = ctx.qry.head;
strbuf_addf(&fullref, "refs/tags/%s", revname);
- if (repo_get_oid(the_repository, fullref.buf, &oid)) {
+ if (repo_get_oid(the_repository, fullref.buf, &oid) && !tag_by_id(revname, &oid)) {
cgit_print_error_page(404, "Not Found", "Bad tag reference: %s", revname);
goto cleanup;
}
obj = parse_object(the_repository, &oid);
if (!obj) {
- cgit_print_error_page(500, "Internal Server Error", "Bad object id: %s", oid_to_hex(&oid));
+ cgit_print_error_page(500, "Internal Server Error", "Unable to read object %s",
+ oid_to_hex(&oid));
goto cleanup;
}
if (obj->type == OBJ_TAG)