diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /lib/gitlab/highlight.rb | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'lib/gitlab/highlight.rb')
-rw-r--r-- | lib/gitlab/highlight.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/gitlab/highlight.rb b/lib/gitlab/highlight.rb index d05ced00a6b..afe1554aec1 100644 --- a/lib/gitlab/highlight.rb +++ b/lib/gitlab/highlight.rb @@ -11,11 +11,9 @@ module Gitlab end def self.too_large?(size) - file_size_limit = Gitlab.config.extra['maximum_text_highlight_size_kilobytes'] + return false unless size.to_i > self.file_size_limit - return false unless size.to_i > file_size_limit - - over_highlight_size_limit.increment(source: "file size: #{file_size_limit}") if Feature.enabled?(:track_file_size_over_highlight_limit) + over_highlight_size_limit.increment(source: "file size: #{self.file_size_limit}") if Feature.enabled?(:track_file_size_over_highlight_limit) true end @@ -51,6 +49,16 @@ module Gitlab attr_reader :context + def self.file_size_limit + if Feature.enabled?(:one_megabyte_file_size_limit) + 1024.kilobytes + else + Gitlab.config.extra['maximum_text_highlight_size_kilobytes'] + end + end + + private_class_method :file_size_limit + def custom_language return unless @language |