Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
1167ef40
Commit
1167ef40
authored
Jul 12, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix markdown rendering for label references that contains `.`
parent
f682c097
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
app/models/label.rb
app/models/label.rb
+2
-2
spec/lib/banzai/filter/label_reference_filter_spec.rb
spec/lib/banzai/filter/label_reference_filter_spec.rb
+13
-13
No files found.
app/models/label.rb
View file @
1167ef40
...
...
@@ -61,7 +61,7 @@ class Label < ActiveRecord::Base
(?:
(?<label_id>
\d
+(?!
\S\w
)
\b
) | # Integer-based label ID, or
(?<label_name>
[A-Za-z0-9_
\-\?
&]+ | # String-based single-word label title, or
[A-Za-z0-9_
\-\?
\.
&]+ | # String-based single-word label title, or
"([^"]*)" # String-based multi-word label surrounded in quotes
)
)
...
...
spec/lib/banzai/filter/label_reference_filter_spec.rb
View file @
1167ef40
...
...
@@ -93,8 +93,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
end
it
'links with adjacent text'
do
doc
=
reference_filter
(
"Label (
#{
reference
}
.)
"
)
expect
(
doc
.
to_html
).
to
match
(
%r(
\(
<a.+><span.+>
#{
label
.
name
}
</span></a>
\
.\)
)
)
doc
=
reference_filter
(
"Label (
#{
reference
}
).
"
)
expect
(
doc
.
to_html
).
to
match
(
%r(
\(
<a.+><span.+>
#{
label
.
name
}
</span></a>
\
)\.
)
)
end
it
'ignores invalid label names'
do
...
...
@@ -117,8 +117,8 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
end
it
'links with adjacent text'
do
doc
=
reference_filter
(
"Label (
#{
reference
}
.)
"
)
expect
(
doc
.
to_html
).
to
match
(
%r(
\(
<a.+><span.+>
#{
label
.
name
}
</span></a>
\
.\)
)
)
doc
=
reference_filter
(
"Label (
#{
reference
}
).
"
)
expect
(
doc
.
to_html
).
to
match
(
%r(
\(
<a.+><span.+>
#{
label
.
name
}
</span></a>
\
)\.
)
)
end
it
'ignores invalid label names'
do
...
...
@@ -129,7 +129,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
end
context
'String-based single-word references with special characters'
do
let
(
:label
)
{
create
(
:label
,
name:
'?gfm&'
,
project:
project
)
}
let
(
:label
)
{
create
(
:label
,
name:
'?g
.
fm&'
,
project:
project
)
}
let
(
:reference
)
{
"
#{
Label
.
reference_prefix
}#{
label
.
name
}
"
}
it
'links to a valid reference'
do
...
...
@@ -137,17 +137,17 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
expect
(
doc
.
css
(
'a'
).
first
.
attr
(
'href'
)).
to
eq
urls
.
namespace_project_issues_url
(
project
.
namespace
,
project
,
label_name:
label
.
name
)
expect
(
doc
.
text
).
to
eq
'See ?gfm&'
expect
(
doc
.
text
).
to
eq
'See ?g
.
fm&'
end
it
'links with adjacent text'
do
doc
=
reference_filter
(
"Label (
#{
reference
}
.)
"
)
expect
(
doc
.
to_html
).
to
match
(
%r(
\(
<a.+><span.+>
\?
g
fm&</span></a>
\.\)
)
)
doc
=
reference_filter
(
"Label (
#{
reference
}
).
"
)
expect
(
doc
.
to_html
).
to
match
(
%r(
\(
<a.+><span.+>
\?
g
\.
fm&</span></a>
\)\.
)
)
end
it
'ignores invalid label names'
do
act
=
"Label
#{
Label
.
reference_prefix
}#{
label
.
name
.
reverse
}
"
exp
=
"Label
#{
Label
.
reference_prefix
}
&mfg?"
exp
=
"Label
#{
Label
.
reference_prefix
}
&mf
.
g?"
expect
(
reference_filter
(
act
).
to_html
).
to
eq
exp
end
...
...
@@ -202,7 +202,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
end
context
'String-based multi-word references with special characters in quotes'
do
let
(
:label
)
{
create
(
:label
,
name:
'gfm & references?'
,
project:
project
)
}
let
(
:label
)
{
create
(
:label
,
name:
'g
.
fm & references?'
,
project:
project
)
}
let
(
:reference
)
{
label
.
to_reference
(
format: :name
)
}
it
'links to a valid reference'
do
...
...
@@ -210,17 +210,17 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
expect
(
doc
.
css
(
'a'
).
first
.
attr
(
'href'
)).
to
eq
urls
.
namespace_project_issues_url
(
project
.
namespace
,
project
,
label_name:
label
.
name
)
expect
(
doc
.
text
).
to
eq
'See gfm & references?'
expect
(
doc
.
text
).
to
eq
'See g
.
fm & references?'
end
it
'links with adjacent text'
do
doc
=
reference_filter
(
"Label (
#{
reference
}
.)"
)
expect
(
doc
.
to_html
).
to
match
(
%r(
\(
<a.+><span.+>gfm & references
\?
</span></a>
\.\)
)
)
expect
(
doc
.
to_html
).
to
match
(
%r(
\(
<a.+><span.+>g
\.
fm & references
\?
</span></a>
\.\)
)
)
end
it
'ignores invalid label names'
do
act
=
%(Label #{Label.reference_prefix}"#{label.name.reverse}")
exp
=
%(Label #{Label.reference_prefix}"?secnerefer & mfg\")
exp
=
%(Label #{Label.reference_prefix}"?secnerefer & mf
.
g\")
expect
(
reference_filter
(
act
).
to_html
).
to
eq
exp
end
...
...
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