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
579c5e31
Commit
579c5e31
authored
May 21, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'rs-issue-1651' into 'master'
Customize the sanitization whitelist only once Fixes #1651 See merge request !687
parents
71b1a2c7
212fe14c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
sanitization_filter.rb
lib/gitlab/markdown/sanitization_filter.rb
+10
-1
No files found.
lib/gitlab/markdown/sanitization_filter.rb
View file @
579c5e31
...
@@ -8,8 +8,10 @@ module Gitlab
...
@@ -8,8 +8,10 @@ module Gitlab
# Extends HTML::Pipeline::SanitizationFilter with a custom whitelist.
# Extends HTML::Pipeline::SanitizationFilter with a custom whitelist.
class
SanitizationFilter
<
HTML
::
Pipeline
::
SanitizationFilter
class
SanitizationFilter
<
HTML
::
Pipeline
::
SanitizationFilter
def
whitelist
def
whitelist
whitelist
=
HTML
::
Pipeline
::
SanitizationFilter
::
WHITELIST
whitelist
=
super
# Only push these customizations once
unless
customized?
(
whitelist
[
:transformers
])
# Allow code highlighting
# Allow code highlighting
whitelist
[
:attributes
][
'pre'
]
=
%w(class)
whitelist
[
:attributes
][
'pre'
]
=
%w(class)
whitelist
[
:attributes
][
'span'
]
=
%w(class)
whitelist
[
:attributes
][
'span'
]
=
%w(class)
...
@@ -26,10 +28,13 @@ module Gitlab
...
@@ -26,10 +28,13 @@ module Gitlab
# Remove `class` attribute from non-highlight spans
# Remove `class` attribute from non-highlight spans
whitelist
[
:transformers
].
push
(
clean_spans
)
whitelist
[
:transformers
].
push
(
clean_spans
)
end
whitelist
whitelist
end
end
private
def
remove_rel
def
remove_rel
lambda
do
|
env
|
lambda
do
|
env
|
if
env
[
:node_name
]
==
'a'
if
env
[
:node_name
]
==
'a'
...
@@ -48,6 +53,10 @@ module Gitlab
...
@@ -48,6 +53,10 @@ module Gitlab
end
end
end
end
end
end
def
customized?
(
transformers
)
transformers
.
last
.
source_location
[
0
]
==
__FILE__
end
end
end
end
end
end
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