summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/string_regex_marker_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/string_regex_marker_spec.rb')
-rw-r--r--spec/lib/gitlab/string_regex_marker_spec.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/spec/lib/gitlab/string_regex_marker_spec.rb b/spec/lib/gitlab/string_regex_marker_spec.rb
index a02be83558c..0cbe44eacf4 100644
--- a/spec/lib/gitlab/string_regex_marker_spec.rb
+++ b/spec/lib/gitlab/string_regex_marker_spec.rb
@@ -23,9 +23,10 @@ RSpec.describe Gitlab::StringRegexMarker do
context 'with multiple occurrences' do
let(:raw) { %{a <b> <c> d} }
let(:rich) { %{a &lt;b&gt; &lt;c&gt; d}.html_safe }
+ let(:regexp) { /<[a-z]>/ }
subject do
- described_class.new(raw, rich).mark(/<[a-z]>/) do |text, left:, right:, mode:|
+ described_class.new(raw, rich).mark(regexp) do |text, left:, right:, mode:|
%{<strong>#{text}</strong>}.html_safe
end
end
@@ -34,6 +35,15 @@ RSpec.describe Gitlab::StringRegexMarker do
expect(subject).to eq(%{a <strong>&lt;b&gt;</strong> <strong>&lt;c&gt;</strong> d})
expect(subject).to be_html_safe
end
+
+ context 'with a Gitlab::UntrustedRegexp' do
+ let(:regexp) { Gitlab::UntrustedRegexp.new('<[a-z]>') }
+
+ it 'marks the matches' do
+ expect(subject).to eq(%{a <strong>&lt;b&gt;</strong> <strong>&lt;c&gt;</strong> d})
+ expect(subject).to be_html_safe
+ end
+ end
end
end
end