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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e9325842
Commit
e9325842
authored
Oct 29, 2019
by
Harish Ramachandran
Committed by
Jan Provaznik
Nov 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor changes and test for passed-in HTML
parent
457edc7d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
app/helpers/markup_helper.rb
app/helpers/markup_helper.rb
+5
-4
spec/helpers/markup_helper_spec.rb
spec/helpers/markup_helper_spec.rb
+6
-0
No files found.
app/helpers/markup_helper.rb
View file @
e9325842
...
@@ -55,10 +55,11 @@ module MarkupHelper
...
@@ -55,10 +55,11 @@ module MarkupHelper
# either pure text or emojis, wrapping anything found in the
# either pure text or emojis, wrapping anything found in the
# requested link
# requested link
fragment
.
children
.
each
do
|
node
|
fragment
.
children
.
each
do
|
node
|
next
unless
node
.
text?
||
node
.
name
==
'gl-emoji'
if
node
.
text?
node
.
replace
(
link_to
(
node
.
text
,
url
,
html_options
))
node
.
replace
(
link_to
(
node
.
text
,
url
,
html_options
))
if
node
.
text?
elsif
node
.
name
==
'gl-emoji'
node
.
replace
(
link_to
(
node
.
to_html
.
html_safe
,
url
,
html_options
))
if
node
.
name
==
'gl-emoji'
node
.
replace
(
link_to
(
node
.
to_html
.
html_safe
,
url
,
html_options
))
end
end
end
end
end
...
...
spec/helpers/markup_helper_spec.rb
View file @
e9325842
...
@@ -232,6 +232,12 @@ describe MarkupHelper do
...
@@ -232,6 +232,12 @@ describe MarkupHelper do
expect
(
doc
.
css
(
'a'
)[
0
].
attr
(
'href'
)).
to
eq
link
expect
(
doc
.
css
(
'a'
)[
0
].
attr
(
'href'
)).
to
eq
link
expect
(
doc
.
css
(
'a'
)[
0
].
text
).
to
eq
'This should finally fix '
expect
(
doc
.
css
(
'a'
)[
0
].
text
).
to
eq
'This should finally fix '
end
end
it
"escapes HTML passed as an emoji"
do
rendered
=
'<gl-emoji><div class="test">test</div></gl-emoji>'
expect
(
helper
.
link_to_html
(
rendered
,
'/foo'
))
.
to
eq
'<a href="/foo"><gl-emoji><div class="test">test</div></gl-emoji></a>'
end
end
end
describe
'#render_wiki_content'
do
describe
'#render_wiki_content'
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