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
e9ecbd3d
Commit
e9ecbd3d
authored
May 19, 2016
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix warning messages with SVG ALLOWED_ELEMENTS
Eliminates "warning: already initialized constant Gitlab::Sanitizers::SVG::ALLOWED_ELEMENTS"
parent
4607323e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
svg.rb
lib/gitlab/sanitizers/svg.rb
+3
-5
whitelist.rb
lib/gitlab/sanitizers/svg/whitelist.rb
+2
-0
No files found.
lib/gitlab/sanitizers/svg.rb
View file @
e9ecbd3d
require_relative
"svg/whitelist"
module
Gitlab
module
Sanitizers
module
SVG
...
...
@@ -12,14 +10,14 @@ module Gitlab
DATA_ATTR_PATTERN
=
/\Adata-(?!xml)[a-z_][\w.\u00E0-\u00F6\u00F8-\u017F\u01DD-\u02AF-]*\z/u
def
scrub
(
node
)
unless
ALLOWED_ELEMENTS
.
include?
(
node
.
name
)
unless
Whitelist
::
ALLOWED_ELEMENTS
.
include?
(
node
.
name
)
node
.
unlink
else
node
.
attributes
.
each
do
|
attr_name
,
attr
|
valid_attributes
=
ALLOWED_ATTRIBUTES
[
node
.
name
]
valid_attributes
=
Whitelist
::
ALLOWED_ATTRIBUTES
[
node
.
name
]
unless
valid_attributes
&&
valid_attributes
.
include?
(
attr_name
)
if
ALLOWED_DATA_ATTRIBUTES_IN_ELEMENTS
.
include?
(
node
.
name
)
&&
if
Whitelist
::
ALLOWED_DATA_ATTRIBUTES_IN_ELEMENTS
.
include?
(
node
.
name
)
&&
attr_name
.
start_with?
(
'data-'
)
# Arbitrary data attributes are allowed. Verify that the attribute
# is a valid data attribute.
...
...
lib/gitlab/sanitizers/svg/whitelist.rb
View file @
e9ecbd3d
...
...
@@ -4,6 +4,7 @@
module
Gitlab
module
Sanitizers
module
SVG
class
Whitelist
ALLOWED_ELEMENTS
=
%w[
a altGlyph altGlyphDef altGlyphItem animate
animateColor animateMotion animateTransform circle clipPath color-profile
...
...
@@ -104,4 +105,5 @@ module Gitlab
}.
freeze
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