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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
747fe752
Commit
747fe752
authored
Aug 20, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove trailing HTML entities from non-Rinku autolinks as well.
parent
2de0935e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
lib/gitlab/markdown/autolink_filter.rb
lib/gitlab/markdown/autolink_filter.rb
+7
-1
spec/lib/gitlab/markdown/autolink_filter_spec.rb
spec/lib/gitlab/markdown/autolink_filter_spec.rb
+10
-0
No files found.
lib/gitlab/markdown/autolink_filter.rb
View file @
747fe752
...
@@ -87,8 +87,14 @@ module Gitlab
...
@@ -87,8 +87,14 @@ module Gitlab
def
autolink_filter
(
text
)
def
autolink_filter
(
text
)
text
.
gsub
(
LINK_PATTERN
)
do
|
match
|
text
.
gsub
(
LINK_PATTERN
)
do
|
match
|
# Remove any trailing HTML entities and store them for appending
# outside the link element. The entity must be marked HTML safe in
# order to be output literally rather than escaped.
match
.
gsub!
(
/((?:&[\w#]+;)+)\z/
,
''
)
dropped
=
(
$1
||
''
).
html_safe
options
=
link_options
.
merge
(
href:
match
)
options
=
link_options
.
merge
(
href:
match
)
content_tag
(
:a
,
match
,
options
)
content_tag
(
:a
,
match
,
options
)
+
dropped
end
end
end
end
...
...
spec/lib/gitlab/markdown/autolink_filter_spec.rb
View file @
747fe752
...
@@ -86,6 +86,16 @@ module Gitlab::Markdown
...
@@ -86,6 +86,16 @@ module Gitlab::Markdown
doc
=
filter
(
"See
#{
link
}
, ok?"
)
doc
=
filter
(
"See
#{
link
}
, ok?"
)
expect
(
doc
.
at_css
(
'a'
).
text
).
to
eq
link
expect
(
doc
.
at_css
(
'a'
).
text
).
to
eq
link
doc
=
filter
(
"See
#{
link
}
..."
)
expect
(
doc
.
at_css
(
'a'
).
text
).
to
eq
link
end
it
'does not include trailing HTML entities'
do
doc
=
filter
(
"See <<<
#{
link
}
>>>"
)
expect
(
doc
.
at_css
(
'a'
)[
'href'
]).
to
eq
link
expect
(
doc
.
text
).
to
eq
"See <<<
#{
link
}
>>>"
end
end
it
'accepts link_attr options'
do
it
'accepts link_attr options'
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