diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2015-09-10 20:45:59 +0300 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2015-09-10 20:45:59 +0300 |
commit | b8c05a069b3204bf7ff5074d1ba747bd1d65fcc2 (patch) | |
tree | 6f35abcf4280115417eb5a2c7d3b52054d5a67a8 /lib | |
parent | 0a2c7fcc648c83402bae70c598d674817a78bc84 (diff) | |
parent | 9d3344adbbfc84ef8abc96366bdfa695293cd6c0 (diff) |
Merge branch 'rescue-syntax-highlighting-errors' into 'master'
Gracefully handle errors in syntax highlighting by leaving the block unformatted
A bug in Rouge caused an Exception:
```undefined method `sub' for :Literal:Symbol```
That caused https://gitlab.com/embeddable-common-lisp/ecl/issues/156 to hit Error 500 and fail to display. If a failure occurs, just render the text as preformatted.
Closes #2433
See merge request !1274
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/markdown/syntax_highlight_filter.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/gitlab/markdown/syntax_highlight_filter.rb b/lib/gitlab/markdown/syntax_highlight_filter.rb index 86f4385753a..f9527c7286e 100644 --- a/lib/gitlab/markdown/syntax_highlight_filter.rb +++ b/lib/gitlab/markdown/syntax_highlight_filter.rb @@ -21,7 +21,11 @@ module Gitlab language = node.attr('class') code = node.text - highlighted = block_code(code, language) + begin + highlighted = block_code(code, language) + rescue + highlighted = "<pre>#{code}</pre>" + end # Replace the parent `pre` element with the entire highlighted block node.parent.replace(highlighted) |