![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
@mattkrick/sanitize-svg
Advanced tools
a small SVG sanitizer to prevent XSS attacks
yarn add @mattkrick/sanitize-svg
Bad actors can put script tags in SVG files.
These script tags are not run when the svg is inside an <img>
,
but if the SVG file is opened directly ("Open image in...") they will run under the image's domain,
which means that bad actor could steal domain-specific context (cookies, local storage, etc.)
Anytime someone tries to upload a svg. Optionally on the client, but definitely on the server.
The output file will be null
NPM's security model is broken by design & this is marginally safer because it prevents namespace & typo attacks.
import sanitizeSVG from '@mattkrick/sanitize-svg'
// file input onSubmit handler
const onSubmit = async (e) => {
const attachedImage = e.currentTarget.files[0]
const cleanImage = await sanitizeSVG(attachedImage)
if (!cleanImage) {
alert('Howdy, hacker')
}
}
// in JSX
<input type='file' onSubmit={onSubmit}/>
import JSDOM from 'jsdom'
import sanitizeSVG from '@mattkrick/sanitize-svg'
const {window} = new JSDOM()
const imageName = 'foo.svg'
const imageBuffer = await fetch(imageName).then(r => r.buffer())
// Buffers don't contain type info, so you should check that on your own
if (imageName.endsWith('.svg')) {
const cleanImage = await sanitizeSVG(imageBuffer, window)
}
MIT
FAQs
a small script to remove script tags from SVGs
The npm package @mattkrick/sanitize-svg receives a total of 3,929 weekly downloads. As such, @mattkrick/sanitize-svg popularity was classified as popular.
We found that @mattkrick/sanitize-svg demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
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.