htmlwhitelist

Last updated:

0 purchases

htmlwhitelist Image
htmlwhitelist Images
Add to Cart

Description:

htmlwhitelist

Html Whitelist #


Introduction
Usage
License and contributors

Introduction #
This library can be used to whitelist html elements, attributes and attribute values.
The main purpose is to process html from an untrusted source and make sure that if the html is rendered by your
application it doesn't contain elements that are not safe.
Usage #
import 'package:htmlwhitelist/htmlwhitelist.dart';

main() {
var contents = '<b>See:</b> <a href="docs.html">the documentation</a>';
var safe = Whitelist.simpleText.safeCopy(contents);
print(safe);
}
copied to clipboard
prints
<b>See:</b> the documentation
copied to clipboard
If you have a DocumentFragment instead of a String you can use the Cleaner instead:
import 'package:htmlwhitelist/htmlwhitelist.dart';
import 'package:html/parser.dart';
import 'package:html/dom.dart';

main() {
var contents = '<b>See:</b> <a href="docs.html">the documentation</a>';

DocumentFragment fragment = parseFragment(contents);
DocumentFragment safeCopy = Whitelist.simpleText.cleaner.safeCopy(fragment);

print(safeCopy.outerHtml);
}
copied to clipboard
prints
<b>See:</b> the documentation
copied to clipboard
License and contributors #

The MIT License, see LICENSE.
For contributors, see AUTHORS.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.