Repair and secure untrusted HTML
clean_text
function.IntoIterator
and Borrow
, so that you can pass slices directly to them.action
, formaction
and ping
as URL attributes for scheme and origin filteringBuilder::url_filter_map
which allows URLs, both relative and absolute, to be pre-filteredBuilder::clean_content_tags
which allows elements to be removed entirely instead of just having the tags removedIn 0.7 and earlier, you would call Ammonia::clean
and get a string out:
let a: String = Ammonia::new().clean(&input);
The 1.0 API is more flexible, returning a Document
struct that can be written to a writer as well as a string. It's also been renamed from ammonia::Ammonia
to ammonia::Builder
. So the equivalent is:
let a: Builder = Builder::new().clean(&input).to_string();
Ammonia
struct is now called Builder
and uses that pattern for better forward compatibilityBuilder::clean()
method now returns a Document
struct instead of a String
(you can use the Document::to_string
method to obtain a String
)keep_cleaned_elements
has changed from being an off-by-default option to the only supported behaviorallowed_classes
means that the class attribute is banned from tag_attributes
(it used to be required)UrlRelative::Custom
, allowing you to write your own relative URL resolverUrlRelative::RewriteWithBase
take a custom URL. This made the url
crate a public dependency.id_prefix
, which can be used to avoid element id
collisions with the rest of the pageBuilder
, to see what everything is currently set toRead
and Write
implementations directly, instead of using references to them (&mut T where T: Read
implements Read
, and the same is true for Write
, so the direct version still allows the user to use references, so it's strictly more flexible)