From 56296f1edadf2bc5f7741cbb3f97cb41f090aac6 Mon Sep 17 00:00:00 2001 From: Jasper Maes Date: Sat, 15 Dec 2018 10:06:56 +0100 Subject: Remove rails4 specific code --- app/controllers/application_controller.rb | 5 +--- .../concerns/invalid_utf8_error_handler.rb | 27 ---------------------- 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 app/controllers/concerns/invalid_utf8_error_handler.rb (limited to 'app/controllers') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7c8c1392c1c..6f0dc2a3a20 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -12,9 +12,6 @@ class ApplicationController < ActionController::Base include EnforcesTwoFactorAuthentication include WithPerformanceBar include SessionlessAuthentication - # this can be removed after switching to rails 5 - # https://gitlab.com/gitlab-org/gitlab-ce/issues/51908 - include InvalidUTF8ErrorHandler unless Gitlab.rails5? before_action :authenticate_user! before_action :enforce_terms!, if: :should_enforce_terms? @@ -157,7 +154,7 @@ class ApplicationController < ActionController::Base def log_exception(exception) Gitlab::Sentry.track_acceptable_exception(exception) - backtrace_cleaner = Gitlab.rails5? ? request.env["action_dispatch.backtrace_cleaner"] : env + backtrace_cleaner = request.env["action_dispatch.backtrace_cleaner"] application_trace = ActionDispatch::ExceptionWrapper.new(backtrace_cleaner, exception).application_trace application_trace.map! { |t| " #{t}\n" } logger.error "\n#{exception.class.name} (#{exception.message}):\n#{application_trace.join}" diff --git a/app/controllers/concerns/invalid_utf8_error_handler.rb b/app/controllers/concerns/invalid_utf8_error_handler.rb deleted file mode 100644 index 44c6d6b0da0..00000000000 --- a/app/controllers/concerns/invalid_utf8_error_handler.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -module InvalidUTF8ErrorHandler - extend ActiveSupport::Concern - - included do - rescue_from ArgumentError, with: :handle_invalid_utf8 - end - - private - - def handle_invalid_utf8(error) - if error.message == "invalid byte sequence in UTF-8" - render_412 - else - raise(error) - end - end - - def render_412 - respond_to do |format| - format.html { render "errors/precondition_failed", layout: "errors", status: 412 } - format.js { render json: { error: 'Invalid UTF-8' }, status: :precondition_failed, content_type: 'application/json' } - format.any { head :precondition_failed } - end - end -end -- cgit v1.2.1