IronFlowDocs

html_sanitize

Sanitize HTML by removing dangerous tags, attributes, and scripts using the ammonia crate.

Parameters

inputstring*
HTML string (supports ${ctx.key})
source_keystring*
Context key containing HTML string
output_keystringdefault "sanitized_html"
Key to store sanitized output
allowed_tagsstring[]default ammonia defaults
Custom set of allowed HTML tags
strip_commentsbooldefault true
Whether to strip HTML comments

*One of input or source_key is required (not both).

Context Output

KeyTypeDescription
{output_key}stringSanitized HTML string

Examples

Basic sanitization

flow:step("sanitize", nodes.html_sanitize({
    input = '<h1>Hello</h1><script>alert("xss")</script>',
}))
-- Output: { sanitized_html = "<h1>Hello</h1>" }

Custom allowed tags

flow:step("sanitize", nodes.html_sanitize({
    input = '<p><b>bold</b> <custom>tag</custom></p>',
    allowed_tags = { "p", "b", "custom" },
}))

From context

flow:step("sanitize", nodes.html_sanitize({
    source_key = "raw_html",
    output_key = "clean_html",
}))

IronFlow documentation

Find the next step

Type a keyword to search the documentation.

to move · Enter to open · Esc to close