Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lucacasonato/ammonia-wasm
WASM bindings for the Ammonia HTML sanitizer
https://github.com/lucacasonato/ammonia-wasm
deno html5 sanitizer wasm
Last synced: 4 months ago
JSON representation
WASM bindings for the Ammonia HTML sanitizer
- Host: GitHub
- URL: https://github.com/lucacasonato/ammonia-wasm
- Owner: lucacasonato
- License: mit
- Created: 2021-07-22T13:35:30.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-09T17:41:12.000Z (over 2 years ago)
- Last Synced: 2024-10-06T10:49:00.215Z (4 months ago)
- Topics: deno, html5, sanitizer, wasm
- Language: TypeScript
- Homepage: https://deno.land/x/ammonia
- Size: 2.68 MB
- Stars: 20
- Watchers: 3
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ammonia-wasm
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/[email protected]/mod.ts)
WASM bindings for the
[Ammonia HTML sanitizer](https://github.com/rust-ammonia/ammonia).> Ammonia is a whitelist-based HTML sanitization library written in Rust. It is
> designed to prevent cross-site scripting, layout breaking, and clickjacking
> caused by untrusted user-provided HTML being mixed into a larger web page.> Ammonia uses [html5ever](https://github.com/servo/html5ever) to parse and
> serialize document fragments the same way browsers do, so it is extremely
> resilient to syntactic obfuscation.> Ammonia parses its input exactly according to the HTML5 specification; it will
> not linkify bare URLs, insert line or paragraph breaks, or convert (C) into ©.
> If you want that, use a markup processor before running the sanitizer.## How to use
```ts
import * as ammonia from "https://deno.land/x/[email protected]/mod.ts";
await ammonia.init();// Simple cleaning with conservative defaults.
ammonia.clean("XSSattack"); // XSS// Custom options
const builder = new ammonia.AmmoniaBuilder();
builder.tags.delete("p"); // strip thetag
const cleaner = builder.build();
ammonia.clean("foobar
"); // foobar
```For exact details on the options on `AmmoniaBuilder` or any other API, view
[deno doc](https://doc.deno.land/https/deno.land/x/[email protected]/mod.ts).## Thanks
Thanks to the authors of Ammonia (@notriddle, and @lnicola), the countless of
contributors to html5ever, and the HTML spec authors.Additional thanks to the @denosaurs folks for the build.ts script this repo
uses.