diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/admin/requests_profiles_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/chaos_controller.rb | 10 | ||||
-rw-r--r-- | app/controllers/concerns/uploads_actions.rb | 13 | ||||
-rw-r--r-- | app/controllers/metrics_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/profiles/keys_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/projects/artifacts_controller.rb | 9 | ||||
-rw-r--r-- | app/controllers/projects/blob_controller.rb | 13 | ||||
-rw-r--r-- | app/controllers/projects/commits_controller.rb | 14 | ||||
-rw-r--r-- | app/controllers/projects/environments_controller.rb | 2 |
9 files changed, 10 insertions, 59 deletions
diff --git a/app/controllers/admin/requests_profiles_controller.rb b/app/controllers/admin/requests_profiles_controller.rb index 64d74ae4231..57f7d3e3951 100644 --- a/app/controllers/admin/requests_profiles_controller.rb +++ b/app/controllers/admin/requests_profiles_controller.rb @@ -11,7 +11,7 @@ class Admin::RequestsProfilesController < Admin::ApplicationController profile = Gitlab::RequestProfiler::Profile.find(clean_name) if profile - render text: profile.content + render html: profile.content else redirect_to admin_requests_profiles_path, alert: 'Profile not found' end diff --git a/app/controllers/chaos_controller.rb b/app/controllers/chaos_controller.rb index b4f46cddbe9..8d518c14b90 100644 --- a/app/controllers/chaos_controller.rb +++ b/app/controllers/chaos_controller.rb @@ -15,7 +15,7 @@ class ChaosController < ActionController::Base duration_taken = (Time.now - start).seconds Kernel.sleep duration_s - duration_taken if duration_s > duration_taken - render text: "OK", content_type: 'text/plain' + render plain: "OK" end def cpuspin @@ -24,14 +24,14 @@ class ChaosController < ActionController::Base rand while Time.now < end_time - render text: "OK", content_type: 'text/plain' + render plain: "OK" end def sleep duration_s = (params[:duration_s]&.to_i || 30).seconds Kernel.sleep duration_s - render text: "OK", content_type: 'text/plain' + render plain: "OK" end def kill @@ -44,13 +44,13 @@ class ChaosController < ActionController::Base secret = ENV['GITLAB_CHAOS_SECRET'] # GITLAB_CHAOS_SECRET is required unless you're running in Development mode if !secret && !Rails.env.development? - render text: "chaos misconfigured: please configure GITLAB_CHAOS_SECRET when using GITLAB_ENABLE_CHAOS_ENDPOINTS outside of a development environment", content_type: 'text/plain', status: 500 + render plain: "chaos misconfigured: please configure GITLAB_CHAOS_SECRET when using GITLAB_ENABLE_CHAOS_ENDPOINTS outside of a development environment", status: :internal_server_error end return unless secret unless request.headers["HTTP_X_CHAOS_SECRET"] == secret - render text: "To experience chaos, please set X-Chaos-Secret header", content_type: 'text/plain', status: 401 + render plain: "To experience chaos, please set X-Chaos-Secret header", status: :unauthorized end end end diff --git a/app/controllers/concerns/uploads_actions.rb b/app/controllers/concerns/uploads_actions.rb index 7a1c7abfb8f..5912fffc058 100644 --- a/app/controllers/concerns/uploads_actions.rb +++ b/app/controllers/concerns/uploads_actions.rb @@ -1,17 +1,11 @@ # frozen_string_literal: true module UploadsActions - extend ActiveSupport::Concern - include Gitlab::Utils::StrongMemoize include SendFileUpload UPLOAD_MOUNTS = %w(avatar attachment file logo header_logo favicon).freeze - included do - prepend_before_action :set_html_format, only: :show - end - def create link_to_file = UploadService.new(model, params[:file], uploader_class).execute @@ -61,13 +55,6 @@ module UploadsActions private - # Explicitly set the format. - # Otherwise rails 5 will set it from a file extension. - # See https://github.com/rails/rails/commit/84e8accd6fb83031e4c27e44925d7596655285f7#diff-2b8f2fbb113b55ca8e16001c393da8f1 - def set_html_format - request.format = :html - end - def uploader_class raise NotImplementedError end diff --git a/app/controllers/metrics_controller.rb b/app/controllers/metrics_controller.rb index 7353be478e1..c2089a0fca3 100644 --- a/app/controllers/metrics_controller.rb +++ b/app/controllers/metrics_controller.rb @@ -15,7 +15,7 @@ class MetricsController < ActionController::Base "# Metrics are disabled, see: #{help_page}\n" end - render text: response, content_type: 'text/plain; version=0.0.4' + render plain: response, content_type: 'text/plain; version=0.0.4' end private diff --git a/app/controllers/profiles/keys_controller.rb b/app/controllers/profiles/keys_controller.rb index 912421e3d08..dcee8eb7e6e 100644 --- a/app/controllers/profiles/keys_controller.rb +++ b/app/controllers/profiles/keys_controller.rb @@ -41,12 +41,12 @@ class Profiles::KeysController < Profiles::ApplicationController user = UserFinder.new(params[:username]).find_by_username if user.present? headers['Content-Disposition'] = 'attachment' - render text: user.all_ssh_keys.join("\n"), content_type: 'text/plain' + render plain: user.all_ssh_keys.join("\n") else return render_404 end rescue => e - render text: e.message + render html: e.message end else return render_404 diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index ae9c17802b9..1a91e07b97f 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -9,7 +9,6 @@ class Projects::ArtifactsController < Projects::ApplicationController before_action :authorize_read_build! before_action :authorize_update_build!, only: [:keep] before_action :extract_ref_name_and_path - before_action :set_request_format, only: [:file] before_action :validate_artifacts!, except: [:download] before_action :entry, only: [:file] @@ -110,12 +109,4 @@ class Projects::ArtifactsController < Projects::ApplicationController render_404 unless @entry.exists? end - - def set_request_format - request.format = :html if set_request_format? - end - - def set_request_format? - request.format != :json - end end diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 873c96a5523..60fabd15333 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -9,7 +9,6 @@ class Projects::BlobController < Projects::ApplicationController include ActionView::Helpers::SanitizeHelper prepend_before_action :authenticate_user!, only: [:edit] - before_action :set_request_format, only: [:edit, :show, :update, :destroy] before_action :require_non_empty_project, except: [:new, :create] before_action :authorize_download_code! @@ -242,18 +241,6 @@ class Projects::BlobController < Projects::ApplicationController .last_for_path(@repository, @ref, @path).sha end - # In Rails 4.2 if params[:format] is empty, Rails set it to :html - # But since Rails 5.0 the framework now looks for an extension. - # E.g. for `blob/master/CHANGELOG.md` in Rails 4 the format would be `:html`, but in Rails 5 on it'd be `:md` - # This before_action explicitly sets the `:html` format for all requests unless `:format` is set by a client e.g. by JS for XHR requests. - def set_request_format - request.format = :html if set_request_format? - end - - def set_request_format? - params[:id].present? && params[:format].blank? && request.format != "json" - end - def show_html environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit } @environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb index 8ba18aacc58..e40a1a1d744 100644 --- a/app/controllers/projects/commits_controller.rb +++ b/app/controllers/projects/commits_controller.rb @@ -12,7 +12,6 @@ class Projects::CommitsController < Projects::ApplicationController before_action :assign_ref_vars, except: :commits_root before_action :authorize_download_code! before_action :set_commits, except: :commits_root - before_action :set_request_format, only: :show def commits_root redirect_to project_commits_path(@project, @project.default_branch) @@ -71,19 +70,6 @@ class Projects::CommitsController < Projects::ApplicationController @commits = set_commits_for_rendering(@commits) end - # Rails 5 sets request.format from the extension. - # Explicitly set to :html. - def set_request_format - request.format = :html if set_request_format? - end - - # Rails 5 sets request.format from extension. - # In this case if the ref ends with `.atom`, it's expected to be the html response, - # not the atom one. So explicitly set request.format as :html to act like rails4. - def set_request_format? - request.format.to_s == "text/html" || @commits.ref.ends_with?("atom") - end - def whitelist_query_limiting Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42330') end diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index de10783df1a..e940f382a19 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -122,7 +122,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController set_workhorse_internal_api_content_type render json: Gitlab::Workhorse.terminal_websocket(terminal) else - render text: 'Not found', status: :not_found + render html: 'Not found', status: :not_found end end |