From 75f35929cb98752b3cdd1529e04d1e2fd4cfbde1 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Thu, 30 Sep 2021 12:47:01 -0400 Subject: [PATCH] archive .asc endpoint: handle junk data --- gitsrht/blueprints/repo.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gitsrht/blueprints/repo.py b/gitsrht/blueprints/repo.py index e6aade5..61db55f 100644 --- a/gitsrht/blueprints/repo.py +++ b/gitsrht/blueprints/repo.py @@ -193,7 +193,10 @@ def lookup_ref(git_repo, ref, path): return commit, ref, "/".join(path) def lookup_signature(git_repo, ref, fmt=['tar', 'tar.gz']): - commit_or_tag = git_repo.revparse_single(ref) + try: + commit_or_tag = git_repo.revparse_single(ref) + except (KeyError, ValueError): + return None, None if not isinstance(commit_or_tag, (pygit2.Commit, pygit2.Tag)): return None, None -- 2.38.4