From c10f7e2d47e59532c5a40694dffa782a3e6a52fc Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 10 2018 09:42:12 +0000 Subject: Fix viewing file if the identifier provider is a commit hash And if this commit hash does not correspond to the identifier of a blob we are no longer able to file asked for, so just return a 404 error in this case. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index b1af3b6..1912ea3 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -551,6 +551,8 @@ def view_file(repo, identifier, filename, username=None, namespace=None): output_type = 'binary' else: output_type = 'binary' + elif isinstance(content, pygit2.Commit): + flask.abort(404, 'File not found') else: content = sorted(content, key=lambda x: x.filemode) for i in content: