diff options
author | Stan Hu <stanhu@gmail.com> | 2016-06-18 10:55:45 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-06-18 13:07:38 -0700 |
commit | 7c9eba891963451a1feb2e5bbef90fdcac1496ff (patch) | |
tree | 51692ed3b138406a8d0bc740eb259076e91e4361 /app/models/issue.rb | |
parent | 00906b5bb6cde8cb60281109060a519a54000c61 (diff) | |
download | gitlab-ce-7c9eba891963451a1feb2e5bbef90fdcac1496ff.tar.gz |
Fix RangeError exceptions when referring to issues or merge requests outside of max database values
When using #XYZ in Markdown text, if XYZ exceeds the maximum value of a signed 32-bit integer, we
get an exception when the Markdown render attempts to run `where(iids: XYZ)`. Introduce a method
that will throw out out-of-bounds values.
Closes #18777
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r-- | app/models/issue.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 1bdf9c011b2..3c5859194b4 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -83,6 +83,10 @@ class Issue < ActiveRecord::Base @link_reference_pattern ||= super("issues", /(?<issue>\d+)/) end + def self.reference_valid?(reference) + reference.to_i > 0 && reference.to_i <= Gitlab::Database::MAX_INT_VALUE + end + def self.sort(method, excluded_labels: []) case method.to_s when 'due_date_asc' then order_due_date_asc |