diff --git a/app/models/concerns/base_label.rb b/app/models/concerns/base_label.rb
index b2faa7509e0c48cfb300a1627f2150753d637366..2153655675086bb0fa4837d61c4b7e62b437c37a 100644
--- a/app/models/concerns/base_label.rb
+++ b/app/models/concerns/base_label.rb
@@ -57,29 +57,12 @@ def text_color
color.contrast
end
- def title=(value)
- if value.blank?
- super
- else
- write_attribute(:title, sanitize_value(value))
- end
- end
- alias_method :name=, :title=
-
- def description=(value)
- if value.blank?
- super
- else
- write_attribute(:description, sanitize_value(value))
- end
+ def name=(value)
+ self.title = value
end
private
- def sanitize_value(value)
- CGI.unescapeHTML(Sanitize.clean(value.to_s))
- end
-
def strip_whitespace_from_title
self[:title] = title&.strip
end
diff --git a/app/models/concerns/timebox.rb b/app/models/concerns/timebox.rb
index 24150aaae7610605f146988f46236c762514706a..ccef4ad57d53d2002e08f467cab27612cdfce44f 100644
--- a/app/models/concerns/timebox.rb
+++ b/app/models/concerns/timebox.rb
@@ -126,10 +126,9 @@ def reference_link_text(from = nil)
self.class.reference_prefix + self.title
end
- def title=(value)
- write_attribute(:title, sanitize_title(value)) if value.present?
+ def name=(value)
+ self.title = value
end
- alias_method :name=, :title=
def timebox_name
model_name.singular
@@ -172,8 +171,4 @@ def dates_within_4_digits
errors.add(:due_date, _("date must not be after 9999-12-31"))
end
end
-
- def sanitize_title(value)
- CGI.unescape_html(Sanitize.clean(value.to_s))
- end
end
diff --git a/ee/spec/models/iteration_spec.rb b/ee/spec/models/iteration_spec.rb
index b6f31284adeb5abd04c7eee15a321064e0ff9bb8..cad387e2509f7f466804ca195efc4b04de9757d2 100644
--- a/ee/spec/models/iteration_spec.rb
+++ b/ee/spec/models/iteration_spec.rb
@@ -311,14 +311,6 @@
end
end
end
-
- describe 'title' do
- subject { build(:iteration, iterations_cadence: iteration_cadence, title: '
') }
-
- it 'sanitizes user intput', :aggregate_failures do
- expect(subject.title).to be_blank
- end
- end
end
describe 'relations' do
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb
index db3fd3d395fc9cd3cef3d257b69f807517de6b0d..f18838b45bdd8fce6db805bd086f57cff5a6ff6c 100644
--- a/spec/models/milestone_spec.rb
+++ b/spec/models/milestone_spec.rb
@@ -102,17 +102,6 @@
allow(subject).to receive(:set_iid).and_return(false)
end
- describe 'title' do
- it { is_expected.to validate_presence_of(:title) }
-
- it 'is invalid if title would be empty after sanitation', :aggregate_failures do
- milestone = build(:milestone, project: project, title: '
')
-
- expect(milestone).not_to be_valid
- expect(milestone.errors[:title]).to include("can't be blank")
- end
- end
-
describe 'milestone_releases' do
let(:milestone) { build(:milestone, project: project) }
diff --git a/spec/support/shared_examples/models/concerns/base_label_shared_examples.rb b/spec/support/shared_examples/models/concerns/base_label_shared_examples.rb
index 895fff8cb710022ff1620b8f91bfd1b7081a7063..bd130f235fca58f00dc5c460a49fd4d2355c66a2 100644
--- a/spec/support/shared_examples/models/concerns/base_label_shared_examples.rb
+++ b/spec/support/shared_examples/models/concerns/base_label_shared_examples.rb
@@ -52,11 +52,6 @@
end
describe '#title' do
- it 'sanitizes title' do
- label = described_class.new(title: 'foo & bar?')
- expect(label.title).to eq('foo & bar?')
- end
-
it 'strips title' do
label = described_class.new(title: ' label ')
label.valid?
@@ -66,11 +61,6 @@
end
describe '#description' do
- it 'sanitizes description' do
- label = described_class.new(description: 'foo & bar?')
- expect(label.description).to eq('foo & bar?')
- end
-
it 'accepts an empty string' do
label = described_class.new(title: 'foo', description: '')
label.valid?
diff --git a/spec/support/shared_examples/models/concerns/timebox_shared_examples.rb b/spec/support/shared_examples/models/concerns/timebox_shared_examples.rb
index 52bedcaa606bc210b1285ac695276556fd21ab3b..f0d1a828bc37108dae29b672e6475a96c4886c98 100644
--- a/spec/support/shared_examples/models/concerns/timebox_shared_examples.rb
+++ b/spec/support/shared_examples/models/concerns/timebox_shared_examples.rb
@@ -57,15 +57,7 @@
let(:timebox) { create(timebox_type, *timebox_args, title: "foo & bar -> 2.2") }
it 'normalizes the title for use as a slug' do
- expect(timebox.safe_title).to eq('foo-bar-22')
- end
- end
-
- describe "#title" do
- let(:timebox) { create(timebox_type, *timebox_args, title: "foo & bar -> 2.2") }
-
- it "sanitizes title" do
- expect(timebox.title).to eq("foo & bar -> 2.2")
+ expect(timebox.safe_title).to eq('bfoo-bar-22b')
end
end