Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
f9897b125cf5
Commit
747fe752
authored
Aug 20, 2015
by
Robert Speicher
Browse files
Remove trailing HTML entities from non-Rinku autolinks as well.
parent
3b23c6f9bb36
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/gitlab/markdown/autolink_filter.rb
View file @
f9897b12
...
...
@@ -87,8 +87,14 @@ def text_parse
def
autolink_filter
(
text
)
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
)
content_tag
(
:a
,
match
,
options
)
content_tag
(
:a
,
match
,
options
)
+
dropped
end
end
...
...
spec/lib/gitlab/markdown/autolink_filter_spec.rb
View file @
f9897b12
...
...
@@ -86,6 +86,16 @@ module Gitlab::Markdown
doc
=
filter
(
"See
#{
link
}
, ok?"
)
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
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