![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.
@aegisjsproject/sanitizer
Advanced tools
A polyfill for the Sanitizer API with various sanitizer configs
@aegisjsproject/sanitizer
Sanitizer API polyfill & config
This is a library & polyfill for the Sanitizer API.
It provides a minimal polyfill for Element.prototype.setHTML()
& Document.parseHTML()
,
as well as config files for HTML, SVG, & MathML. Please note, however, that the
default sanitizer config in these sanitizer methods only support HTML by default.
The "base" config (not what is used by default) DOES add support for <svg>
,
and the "complete" config supports <svg>
& <math>
.
This helps prevent XSS via:
onclick
<a href="javascript:...">
<script>
s and <style>
simport '@aegijsproject/sanitizer/polyfill.js';
import { sanitizer } from '@aegisjsproject/sanitizer/config/base.js';
document.body.setHTML(`
<header id="header">
<h1 onclick="alert(location.href)" data-foo="bar">Hello, World!</h1>
</header>
<nav id="nav" class="flex row">
<button type="button" popovertarget="bacon" popovertargetaction="show" accesskey="b">Show Bacon Ipsum</button>
<a href="#foo">Normal Link</a>
<a href="javascript:alert('javascript:')"><code>javascript:</code> Link</a>
<a href="data:text/plain,Not%20Allowed" target="_blank"><code>data:</code> Link</a>
<a href="${URL.createObjectURL(file)}" target="_blank"><code>blob:</code> Link</a>
</nav>
<main id="main"></main>
<div popover="auto" id="bacon">
<div>
<b>Bacon Ipsum</b>
<button type="button" popovertarget="bacon" popovertargetaction="hide">
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="16" viewBox="0 0 12 16" fill="currentColor" role="presentation" aria-label="Close Popover">
<path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"/>
</svg>
</button>
</div>
<p>Bacon ipsum dolor amet pork belly frankfurter drumstick jowl brisket capicola
short ribs.Cow chislic ham hock t-bone shoulder salami rump corned beef spare
ribs prosciutto bresaola picanha drumstick. Swine tail pork belly ribeye beef
kielbasa. Beef cupim ball tip pastrami spare ribs strip steak tongue salam
venison. Venison cupim meatball strip steak meatloaf prosciutto buffalo
frankfurter hamburger flank boudin.</p>
</div>
`, sanitizer);
const sanitizer = {
elements: ['span', 'div', 'p', 'code', 'pre', 'blockquote', 'img', 'a'],
attributes: ['href', 'src', 'loading', 'height', 'width', 'class', 'alt', 'target'],
};
fetch('https://api.example.com/comments')
.then(resp => resp.json())
.then(comments => {
document.querySelector('.comments').append(...comments.map(comment => {
const el = document.createElement('div');
el.setHTML(comment.body, sanitizer);
return el;
}));
});
import { elements, attributes } from '@aegisjsproject/sanitizer/config/html.js';
const sanitizer = {
elements: ['hello-world', ...elements],
attributes: ['foo', ...attributes],
};
document.querySelector('.container').setHTML(`
<hello-world foo="bar"></hello-world>
`, sanitizer);
innerHTML
, where supported)if ('trustedTypes' in globalThis) {
trustedTypes.createPolicy('default', {
createHTML(input) {
const el = document.createElement('div');
el.setHTML(input);
return el.innerHTML;
}
});
}
[v0.1.3] - 2024-11-06
setHTMLUnsafe()
instead of innerHTML
(supports declarative Shadow DOM)shadowrootclonable
and shadowrootserializable
in default HTML attribute listtrust-policy.js
module policy creationmain
and module
FAQs
A polyfill for the Sanitizer API with various sanitizer configs
The npm package @aegisjsproject/sanitizer receives a total of 0 weekly downloads. As such, @aegisjsproject/sanitizer popularity was classified as not popular.
We found that @aegisjsproject/sanitizer 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.