Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize css values #21

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Sanitize css values #21

wants to merge 5 commits into from

Conversation

hyan7
Copy link

@hyan7 hyan7 commented Aug 22, 2017

Before you could only white-list certain attributes but not their values. I added the ability to specify values you want to white-list in the style attribute to filter out unwanted style values.

You can specify what styles you allow in the 'styles' array and what values you allow in certain style attributes through the 'cssValues' object, such as:
var sanitize = new Sanitize({
elements: ['a', 'br', 'li', 'ol', 'p', 'ul', 'span'],
attributes: {
a: ['data-id', 'href', 'target'],
span: ['class'],
'ALL': ['style']
},
protocols: {
a: { href: ['http', 'https', 'smartsheet'] }
},
styles: ["color", "background-color", "font-family", "font-size"],
cssValues: {
color: ["black", "red", "gray", "grey", "yellow", "white"],
backgroundColor: ["black", "red", "gray", "grey", "yellow", "white"],
fontFamily:["times new roman", "tahoma", "arial", "verdana"],
fontSize:["8pt", "9pt", "10pt", "12pt", "14pt", "16pt", "18pt", "20pt", "24pt", "28pt", "32pt", "36pt"]
}
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants