Class HtmlSanitizeTool
A built-in tool for cleaning HTML by stripping tags or sanitizing dangerous elements.
Can either strip all tags to produce plain text, or selectively remove dangerous elements (scripts, event handlers, javascript URIs) while preserving safe formatting tags.
public sealed class HtmlSanitizeTool : IBuiltInTool, ITool, IToolMetadata
- Inheritance
-
HtmlSanitizeTool
- Implements
- Inherited Members
Examples
var tool = new HtmlSanitizeTool();
var result = await tool.InvokeAsync(@"{""html"":""<b>hello</b><script>evil</script>""}");
Remarks
Uses regex-based parsing. For complex HTML, consider a proper HTML parser library.
Properties
- Description
Gets a concise description of what the tool does.
- InputSchema
Gets the JSON Schema defining the expected input arguments.
- Name
Gets the stable, unique identifier for this tool.
Methods
- InvokeAsync(string, CancellationToken)
Executes the tool with the specified JSON arguments.