BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
9a048a6e
Commit
9a048a6e
authored
Apr 12, 2017
by
blackst0ne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove heading and trailing spaces from label's color and title
parent
01adf920
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
0 deletions
+26
-0
label.rb
app/models/label.rb
+6
-0
fix_spaces_in_label_title.yml
changelogs/unreleased/fix_spaces_in_label_title.yml
+4
-0
label_spec.rb
spec/models/label_spec.rb
+16
-0
No files found.
app/models/label.rb
View file @
9a048a6e
...
...
@@ -21,6 +21,8 @@ class Label < ActiveRecord::Base
has_many
:issues
,
through: :label_links
,
source: :target
,
source_type:
'Issue'
has_many
:merge_requests
,
through: :label_links
,
source: :target
,
source_type:
'MergeRequest'
before_validation
:strip_whitespace_from_title_and_color
validates
:color
,
color:
true
,
allow_blank:
false
# Don't allow ',' for label titles
...
...
@@ -193,4 +195,8 @@ class Label < ActiveRecord::Base
def
sanitize_title
(
value
)
CGI
.
unescapeHTML
(
Sanitize
.
clean
(
value
.
to_s
))
end
def
strip_whitespace_from_title_and_color
%w(color title)
.
each
{
|
attr
|
self
[
attr
]
=
self
[
attr
]
&
.
strip
}
end
end
changelogs/unreleased/fix_spaces_in_label_title.yml
0 → 100644
View file @
9a048a6e
---
title
:
Remove heading and trailing spaces from label's color and title
merge_request
:
10603
author
:
blackst0ne
spec/models/label_spec.rb
View file @
9a048a6e
...
...
@@ -42,11 +42,27 @@ describe Label, models: true do
end
end
describe
'#color'
do
it
'strips color'
do
label
=
described_class
.
new
(
color:
' #abcdef '
)
label
.
valid?
expect
(
label
.
color
).
to
eq
(
'#abcdef'
)
end
end
describe
'#title'
do
it
'sanitizes title'
do
label
=
described_class
.
new
(
title:
'<b>foo & bar?</b>'
)
expect
(
label
.
title
).
to
eq
(
'foo & bar?'
)
end
it
'strips title'
do
label
=
described_class
.
new
(
title:
' label '
)
label
.
valid?
expect
(
label
.
title
).
to
eq
(
'label'
)
end
end
describe
'priorization'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment