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
3e29936a
Commit
3e29936a
authored
Mar 14, 2017
by
Eric Eastwood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix first line markdown helper for user profile activity stream
Fix
https://gitlab.com/gitlab-org/gitlab-ce/issues/29425
parent
ffcddb29
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
5 deletions
+21
-5
events_helper.rb
app/helpers/events_helper.rb
+2
-2
gitlab_markdown_helper.rb
app/helpers/gitlab_markdown_helper.rb
+1
-1
gitlab_markdown_helper_spec.rb
spec/helpers/gitlab_markdown_helper_spec.rb
+18
-2
No files found.
app/helpers/events_helper.rb
View file @
3e29936a
...
...
@@ -165,8 +165,8 @@ module EventsHelper
sanitize
(
text
,
tags:
%w(a img b pre code p span)
,
attributes:
Rails
::
Html
::
WhiteListSanitizer
.
allowed_attributes
+
[
'style'
]
tags:
%w(a img
gl-emoji
b pre code p span)
,
attributes:
Rails
::
Html
::
WhiteListSanitizer
.
allowed_attributes
+
[
'style'
,
'data-name'
,
'data-unicode-version'
]
)
end
...
...
app/helpers/gitlab_markdown_helper.rb
View file @
3e29936a
...
...
@@ -172,7 +172,7 @@ module GitlabMarkdownHelper
# text hasn't already been truncated, then append "..." to the node contents
# and return true. Otherwise return false.
def
truncate_if_block
(
node
,
truncated
)
if
node
.
element?
&&
node
.
description
.
block?
&&
!
truncated
if
node
.
element?
&&
node
.
description
&
.
block?
&&
!
truncated
node
.
inner_html
=
"
#{
node
.
inner_html
}
..."
if
node
.
next_sibling
true
else
...
...
spec/helpers/gitlab_markdown_helper_spec.rb
View file @
3e29936a
...
...
@@ -152,9 +152,8 @@ describe GitlabMarkdownHelper do
end
describe
'#first_line_in_markdown'
do
let
(
:text
)
{
"@
#{
user
.
username
}
, can you look at this?
\n
Hello world
\n
"
}
it
'truncates Markdown properly'
do
text
=
"@
#{
user
.
username
}
, can you look at this?
\n
Hello world
\n
"
actual
=
first_line_in_markdown
(
text
,
100
,
project:
project
)
doc
=
Nokogiri
::
HTML
.
parse
(
actual
)
...
...
@@ -169,6 +168,23 @@ describe GitlabMarkdownHelper do
expect
(
doc
.
content
).
to
eq
"@
#{
user
.
username
}
, can you look at this?..."
end
it
'truncates Markdown with emoji properly'
do
text
=
"foo :wink:
\n
bar :grinning:"
actual
=
first_line_in_markdown
(
text
,
100
,
project:
project
)
doc
=
Nokogiri
::
HTML
.
parse
(
actual
)
# Make sure we didn't create invalid markup
# But also account for the 2 errors caused by the unknown `gl-emoji` elements
expect
(
doc
.
errors
.
length
).
to
eq
(
2
)
expect
(
doc
.
css
(
'gl-emoji'
).
length
).
to
eq
(
2
)
expect
(
doc
.
css
(
'gl-emoji'
)[
0
].
attr
(
'data-name'
)).
to
eq
'wink'
expect
(
doc
.
css
(
'gl-emoji'
)[
1
].
attr
(
'data-name'
)).
to
eq
'grinning'
expect
(
doc
.
content
).
to
eq
"foo 😉
\n
bar 😀"
end
end
describe
'#cross_project_reference'
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