From 95ac3953dad9f9e7732c2f9e6775cad763e7e418 Mon Sep 17 00:00:00 2001 From: tdurieux Date: Wed, 9 May 2018 23:42:23 +0200 Subject: [PATCH] handle README file --- server.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/server.py b/server.py index f7d4c08..fd992e2 100644 --- a/server.py +++ b/server.py @@ -102,7 +102,7 @@ class Anonymous_Github: return "" if file.size > 1000000: return Markup("The file %s is too big to be anonymized (beyond 1MB, Github limit)" % (file.name)) - if ".md" in file.name: + if ".md" in file.name or file.name == file.name.upper() or "changelog" == file.name.lower(): return Markup("
%s
" % remove_terms( self.github.render_markdown(file.decoded_content.decode('utf-8')).decode('utf-8'), repository_configuration)) @@ -197,7 +197,7 @@ class Anonymous_Github: content_type = 'text/plain; charset=utf-8' if ".html" in file_name: content_type = 'text/html; charset=utf-8' - if ".md" in file_name: + if ".md" in file_name or file.name == file.name.upper(): content_type = 'text/html; charset=utf-8' if ".jpg" in file_name \ or ".png" in file_name \ @@ -312,7 +312,7 @@ class Anonymous_Github: if type(current_file) is not github.ContentFile.ContentFile: files = g_repo.get_git_tree(g_commit.sha) for f in current_file: - if f.name.lower() == "readme.md" or f.name.lower() == "index.html": + if f.name.lower() == "readme" or f.name.lower() == "index.html": current_file = f break elif current_file.type == 'file': @@ -376,7 +376,6 @@ class Anonymous_Github: content = get_content(current_file, files, clean_path, repository_configuration, g_repo) content_type = get_type_content(current_file.name, clean_path, repository_configuration, g_repo) - return content, {'Content-Type': content_type} @application.route('/', methods=['GET'])