diff options
author | Robert Speicher <robert@gitlab.com> | 2016-08-25 22:08:38 +0300 |
---|---|---|
committer | Ruben Davila <rdavila84@gmail.com> | 2016-08-26 19:33:49 +0300 |
commit | 32a80b2614b959b970a4b650c2a8886940a60b8c (patch) | |
tree | 708a98d5ca9c7eddeecc812a9e27e959701f16b7 /lib | |
parent | b15d67994b817a94c53d906a21266040134b47fb (diff) |
Merge branch '21247-mergerequestscontroller-conflicts-may-fail-with-iso-8859-data' into 'master'
Handle non-UTF-8 conflicts gracefully
## What does this MR do?
If a conflict file isn't in a UTF-8-compatible encoding, we can't resolve it in the UI.
## What are the relevant issue numbers?
Closes #21247.
See merge request !5961
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/conflict/parser.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/gitlab/conflict/parser.rb b/lib/gitlab/conflict/parser.rb index 6eccded7872..2d4d55daeeb 100644 --- a/lib/gitlab/conflict/parser.rb +++ b/lib/gitlab/conflict/parser.rb @@ -13,10 +13,19 @@ module Gitlab class UnmergeableFile < ParserError end + class UnsupportedEncoding < ParserError + end + def parse(text, our_path:, their_path:, parent_file: nil) raise UnmergeableFile if text.blank? # Typically a binary file raise UnmergeableFile if text.length > 102400 + begin + text.to_json + rescue Encoding::UndefinedConversionError + raise UnsupportedEncoding + end + line_obj_index = 0 line_old = 1 line_new = 1 |