Commit 9fe8c74d authored by Douwe Maan's avatar Douwe Maan
Browse files

Merge branch 'lexer_error_workaround' into 'master'

workaround for buggy lexers

It seems that some lexers can be buggy when used together with git blame.
This results in a 500 error when a user tries to open the blame page in some cases.
The workaround is pretty simple. Not only fall back to plaintext when the file content can't be guessed, but also when the lexer fails.

This closes #1521 and #1646

/cc @DouweM @JobV It would be awesome to have this in a patch release for 7.11 or even in the release. But that's probably to late.

See merge request !683
......@@ -4,6 +4,7 @@ v 7.12.0 (unreleased)
- Allow to configure location of the `.gitlab_shell_secret` file. (Jakub Jirutka)
v 7.11.0 (unreleased)
- Fall back to Plaintext when Syntaxhighlighting doesn't work. Fixes some buggy lexers (Hannes Rosenögger)
- Fix broken view when viewing history of a file that includes a path that used to be another file (Stan Hu)
- Don't show duplicate deploy keys
- Fix commit time being displayed in the wrong timezone in some cases (Hannes Rosenögger)
......@@ -9,11 +9,13 @@ def highlight(blob_name, blob_content, nowrap = false)
lexer = Rugments::Lexer.guess(filename: blob_name, source: blob_content)
rescue Rugments::Lexer::AmbiguousGuess
result = formatter.format(lexer.lex(blob_content)).html_safe
lexer = Rugments::Lexers::PlainText
result = formatter.format(lexer.lex(blob_content)).html_safe
def no_highlight_files
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment