![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
inject-stylesheet
Advanced tools
Create a style element with CSS properties, filtering input using a allowlist or blocklist
This library takes a blocklist (or allowlist) of CSS properties and sanitizes for known CSS exploits.
Where mentioned, styles
is an object with its keys being CSS selectors and values being CSS property key-value pairs.
var stylesheet = injectStylesheet.injectWithBlocklist(styles [, blocklist]);
var stylesheet = injectStylesheet.injectWithAllowlist(styles [, allowlist]);
After usage, stylesheet
will refer to the <style>
tag that was injected into the <head>
of the document.
var injectStylesheet = require("inject-stylesheet");
var styles = {
input: {
"font-size": "16pt",
color: "#3A3A3A",
},
".invalid": {
color: "tomato",
},
"@media screen and (max-width: 700px)": {
input: {
"font-size": "14pt",
},
},
};
var allowlist = ["font-size", "color"];
var blocklist = ["background", "display"];
injectStylesheet.injectWithBlocklist(styles, blocklist);
injectStylesheet.injectWithAllowlist(styles, allowlist);
Selectors are filtered for things such as {}
, @import
, etc.
Keys are filtered based on whether or not a blocklist or allowlist was given. injectStylesheet
will assume that its second parameter is a blocklist unless the third parameter is true
, which will designate it as a allowlist. This listing is used to filter the given CSS properties for exclusion or inclusion.
Values are checked against usages of url()
, evaluate()
, and other potentially abused and powerful CSS functions.
All modern browsers, and IE9+
4.0.0
Breaking Changes
DOMException
errors when calling insertRule
while
inserting stylesheetFAQs
Create a style element with CSS properties, filtering input using a allowlist or blocklist
The npm package inject-stylesheet receives a total of 169,694 weekly downloads. As such, inject-stylesheet popularity was classified as popular.
We found that inject-stylesheet demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.