Commit bb35021c authored by Stan Hu's avatar Stan Hu

Ignore out of range epic IDs

Including a Markdown reference with a large epic ID
(e.g. `&1161452270761535925900804973910297`) would cause an Error 500
with `ActiveModel::RangeError`. To fix this, we implement `reference_valid?`
for the `Epic` model.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/57367
parent 66110570
......@@ -107,6 +107,10 @@ module EE
end
end
def reference_valid?(reference)
reference.to_i > 0 && reference.to_i <= ::Gitlab::Database::MAX_INT_VALUE
end
def link_reference_pattern
%r{
(?<url>
......
......@@ -69,6 +69,12 @@ describe Banzai::Filter::EpicReferenceFilter do
expect(doc(text).to_s).to eq(ERB::Util.html_escape_once(text))
end
it 'ignores out of range epic IDs' do
text = "Check &1161452270761535925900804973910297"
expect(doc(text).to_s).to eq(ERB::Util.html_escape_once(text))
end
it 'does not process links containing epic numbers followed by text' do
href = "#{reference}st"
link = doc("<a href='#{href}'></a>").css('a').first.attr('href')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment