summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorHannes Rosenögger <123haynes@gmail.com>2015-05-20 15:46:40 +0200
committerHannes Rosenögger <123haynes@gmail.com>2015-05-20 16:16:27 +0200
commitdfce7b62f7e126a0891f81abc0bda20cfb7a58b5 (patch)
tree5e2372c6b39f2ddc57d2aed02685430112f53a10 /app/helpers
parent76a758234ac29ba2c859cb50fec6e6374e4a8742 (diff)
downloadgitlab-ce-dfce7b62f7e126a0891f81abc0bda20cfb7a58b5.tar.gz
workaround for buggy lexers
if something goes wrong, fall back to the plaintext lexer
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/blob_helper.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index 885ac5f85b8..9fe5f82f02f 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -9,11 +9,13 @@ module BlobHelper
begin
lexer = Rugments::Lexer.guess(filename: blob_name, source: blob_content)
- rescue Rugments::Lexer::AmbiguousGuess
+ result = formatter.format(lexer.lex(blob_content)).html_safe
+ rescue
lexer = Rugments::Lexers::PlainText
+ result = formatter.format(lexer.lex(blob_content)).html_safe
end
- formatter.format(lexer.lex(blob_content)).html_safe
+ result
end
def no_highlight_files