diff options
Diffstat (limited to 'app/workers/post_receive.rb')
-rw-r--r-- | app/workers/post_receive.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index ecc6c8e53a3..0c3ee6ba4ff 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -21,7 +21,9 @@ class PostReceive return false end - changes = changes.lines if changes.kind_of?(String) + changes = Base64.decode64(changes) unless changes.include?(" ") + changes = utf8_encode_changes(changes) + changes = changes.lines changes.each do |change| oldrev, newrev, ref = change.strip.split(' ') @@ -41,6 +43,19 @@ class PostReceive end end + def utf8_encode_changes(changes) + changes = changes.dup + + changes.force_encoding("UTF-8") + return changes if changes.valid_encoding? + + # Convert non-UTF-8 branch/tag names to UTF-8 so they can be dumped as JSON. + detection = CharlockHolmes::EncodingDetector.detect(changes) + return changes unless detection && detection[:encoding] + + CharlockHolmes::Converter.convert(changes, detection[:encoding], 'UTF-8') + end + def log(message) Gitlab::GitLogger.error("POST-RECEIVE: #{message}") end |