Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
d9f11fa6
Unverified
Commit
d9f11fa6
authored
Jan 23, 2019
by
Torkel Ödegaard
Committed by
GitHub
Jan 23, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15005 from grafana/xss-filter-allow-class-style
XSS sanitizer allows class and style attributes
parents
909d8907
5c72e4e6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletions
+17
-1
public/app/core/utils/text.ts
+17
-1
No files found.
public/app/core/utils/text.ts
View file @
d9f11fa6
...
...
@@ -44,9 +44,25 @@ export function findMatchesInText(haystack: string, needle: string): TextMatch[]
return
matches
;
}
const
XSSWL
=
Object
.
keys
(
xss
.
whiteList
).
reduce
((
acc
,
element
)
=>
{
acc
[
element
]
=
xss
.
whiteList
[
element
].
concat
([
'class'
,
'style'
]);
return
acc
;
},
{});
const
sanitizeXSS
=
new
xss
.
FilterXSS
({
whiteList
:
XSSWL
});
/**
* Returns string safe from XSS attacks.
*
* Even though we allow the style-attribute, there's still default filtering applied to it
* Info: https://github.com/leizongmin/js-xss#customize-css-filter
* Whitelist: https://github.com/leizongmin/js-css-filter/blob/master/lib/default.js
*/
export
function
sanitize
(
unsanitizedString
:
string
):
string
{
try
{
return
x
ss
(
unsanitizedString
);
return
sanitizeXSS
.
proce
ss
(
unsanitizedString
);
}
catch
(
error
)
{
console
.
log
(
'String could not be sanitized'
,
unsanitizedString
);
return
unsanitizedString
;
...
...
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