diff --git a/doc/configuration.rst b/doc/configuration.rst index 035a481..ce38745 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -1261,6 +1261,17 @@ validate new project name. Defaults to: ``^[a-zA-z0-9_][a-zA-Z0-9-_]*$`` +FILE_SIZE_HIGHLIGHT +~~~~~~~~~~~~~~~~~~~ + +This configuration key allows to specify the maximum number of characters a file +or diff should have to have syntax highlighting. Everything above this limit +will not have syntax highlighting as this is a memory intensive procedure that +easily leads to out of memory error on large files or diff. + +Defaults to: 5000 + + Deprecated configuration keys ----------------------------- diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 2574c94..c4840b5 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -70,10 +70,6 @@ from pagure.decorators import ( _log = logging.getLogger(__name__) -# Number of characters to determine that a file is "huge" -# Huge files will not get syntax highlighting -HUGEFILE = 5000 - def get_git_url_ssh(): """ Return the GIT SSH URL to be displayed in the UI based on the @@ -560,7 +556,8 @@ def view_file(repo, identifier, filename, username=None, namespace=None): content, safe = pagure.doc_utils.convert_readme(content.data, ext) output_type = 'markup' elif 'data' in dir(content) \ - and len(content.data) < HUGEFILE \ + and len(content.data) < pagure_config.get( + 'FILE_SIZE_HIGHLIGHT', 5000) \ and not isbinary: file_content = None try: