Configures HTML sanitization in Orchard Core using the HtmlSanitizer service for XSS prevention. Covers allowed tags/attributes, scheme allowlists, Razor/Liquid helpers, and per-field sanitization settings.
Ships in orchardcore. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an Orchard Core expert. Generate HTML sanitization configurations and custom sanitizer settings for Orchard Core.
HtmlBodyPart, HtmlField, HtmlMenuItemPart, MarkdownBodyPart, and MarkdownField.Sanitize Html option (SanitizeHtml = false) for trusted output.@Orchard.SanitizeHtml() Razor helper, the sanitize_html Liquid filter, or IHtmlSanitizerService.Sanitize() in code.class attribute, allowing mailto and tel schemes, and removing the form tag.ConfigureHtmlSanitizer during service registration; multiple calls are combined.| Part / Field | Pipeline before sanitization |
|---|---|
HtmlBodyPart | Authored HTML, then shortcodes. |
HtmlField | Authored HTML, then shortcodes. |
HtmlMenuItemPart | Sanitized on a cloned content item when the menu renders; unsafe URL schemes are rejected. |
MarkdownBodyPart | Markdown converted to HTML, then shortcodes. |
MarkdownField | Markdown converted to HTML, then shortcodes. |
This applies consistently to Detail, Summary, Preview, BodyAspect, GraphQL
rendered HTML, and the MarkdownToHtmlAsync Razor helper. LiquidPart and
LiquidField have no sanitize setting because their output may not be HTML.
Because the stored source is unsanitized, render the part or field shape (or
sanitize explicitly) instead of writing stored Html with raw:
{{ Model.Content.HtmlBodyPart | shape_render }}
{{ Model.ContentItem.Content.Article.Summary.Html | sanitize_html | raw }}
Orchard Core modifies the base HtmlSanitizer defaults:
| Change | Description |
|---|---|
Allow class attribute | The class attribute is added to the allowed attributes list. |
Allow mailto scheme | The mailto: URI scheme is allowed in links. |
Allow tel scheme | The tel: URI scheme is allowed in links. |
Remove form tag | The <form> tag is removed from the allowed tags list. |
Content is sanitized each time it is displayed. HtmlSanitizerService caches
the sanitized result of fragments up to 64K characters, reused only by the same
tenant, so repeated displays skip parsing. The cache is shared by all tenants,
so its size (about 8 MB at most) doesn't grow with the number of tenants, and
entries not read for 10 minutes are evicted. Consequently, actions
registered with ConfigureHtmlSanitizer(), including sanitizer event handlers
such as PostProcessNode, must return the same result for the same input;
do not make them depend on the current user, request, or time.
@Orchard.SanitizeHtml((string)Model.ContentItem.Content.HtmlBodyPart.Html)
public sealed class CommentFormatter
{
private readonly IHtmlSanitizerService _htmlSanitizerService;
public CommentFormatter(IHtmlSanitizerService htmlSanitizerService)
{
_htmlSanitizerService = htmlSanitizerService;
}
public string Format(string html)
=> _htmlSanitizerService.Sanitize(html);
}
IHtmlSanitizerService lives in OrchardCore.Infrastructure.Html.
builder.Services
.AddOrchardCms()
.ConfigureServices(tenantServices =>
tenantServices.ConfigureHtmlSanitizer((sanitizer) =>
{
// Allow additional URI schemes.
sanitizer.AllowedSchemes.Add("ftp");
sanitizer.AllowedSchemes.Add("data");
}));
builder.Services
.AddOrchardCms()
.ConfigureServices(tenantServices =>
tenantServices.ConfigureHtmlSanitizer((sanitizer) =>
{
// Allow <iframe> tags for embedded content.
sanitizer.AllowedTags.Add("iframe");
}));
builder.Services
.AddOrchardCms()
.ConfigureServices(tenantServices =>
tenantServices.ConfigureHtmlSanitizer((sanitizer) =>
{
// Allow data attributes and srcset.
sanitizer.AllowDataAttributes = true;
sanitizer.AllowedAttributes.Add("srcset");
}));
builder.Services
.AddOrchardCms()
.ConfigureServices(tenantServices =>
tenantServices.ConfigureHtmlSanitizer((sanitizer) =>
{
// Disallow inline styles and embedded media.
sanitizer.AllowedAttributes.Remove("style");
sanitizer.AllowedTags.Remove("video");
}));
builder.Services
.AddOrchardCms()
.ConfigureServices(tenantServices =>
tenantServices.ConfigureHtmlSanitizer((sanitizer) =>
{
// Allow iframes for video embeds.
sanitizer.AllowedTags.Add("iframe");
// Allow additional URI schemes.
sanitizer.AllowedSchemes.Add("ftp");
// Allow the target attribute on links.
sanitizer.AllowedAttributes.Add("target");
}));
To disable sanitization for a specific field or part:
HtmlBodyPart).Or in a migration: .WithSettings(new HtmlBodyPartSettings { SanitizeHtml = false }).
Only do this when every editor of the content type is trusted.
| Scenario | Configuration |
|---|---|
| Allow YouTube/Vimeo embeds | AllowedTags.Add("iframe") |
| Allow FTP links | AllowedSchemes.Add("ftp") |
| Allow data URIs for inline images | AllowedSchemes.Add("data") |
| Allow custom data attributes | AllowDataAttributes = true |
Allow heading ids from Markdown autoidentifiers | AllowedAttributes.Add("id") |
| Allow target attribute on links | AllowedAttributes.Add("target") |
| Block all inline styles | AllowedAttributes.Remove("style") |
Html directly must now
sanitize it themselves.Official Orchard Core videos shown on the documentation page:
What SKILL.md sets; muted values are Claude Code's defaults
/orchardcore:orchardcore-sanitizerfrom orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin orchardcore140 skills in this plugin
/orchardcore-adminGuidance for the Orchard Core admin panel, including admin controllers and routes, admin menu registration with AdminNavigationProvider, ocat editor forms grouped in cards, admin pages rendering Model.Editor, the UI text casing standard, TheAdmin layout and menu colors, admin branding, the Navbar shape, the Ctrl+K quick navigation palette and QuickNavigationSource, AdminSettings such as MenuBehavior, ShowBreadcrumb, DisplayQuickNavigation, DisplayTitlesInTopbar and ActionsLayout, the AdminDashboard shape, settings pages, and admin filters and zones. Use this skill when requests mention the Orchard Core admin panel, TheAdmin, admin controllers, admin menu registration, an icon on an admin menu item, the AdminSettings recipe step, quick navigation, navigation menu behavior, the admin URL prefix, UI text casing. Strong matches include OrchardCore.Admin, AdminSettings, AdminPermissions, AdminOptions, AdminAttribute, SiteDisplayDriver, IDisplayManager./orchardcore-admin-dashboardSkill for creating admin dashboard widgets in Orchard Core. Covers the DashboardWidget stereotype, DashboardPart position and sizing, the built-in HtmlDashboardWidget, ContentsMetadata and ContentsTags widget types, custom widget content types via recipe or migration, arranging widgets in Manage Dashboard mode, widget template customization, provisioning widgets with recipes, dashboard permissions, the DashboardBreadcrumbProvider Dashboard ancestor, and the AdminDashboardContent shape used when the feature is disabled. Use this skill when requests mention Orchard Core Admin Dashboard, Create and Configure Dashboard Widgets, Enabling Admin Dashboard, Widget Configuration Properties, dashboard widget recipes, Dashboard breadcrumb, or related implementation, setup, or troubleshooting work. Strong matches include OrchardCore.AdminDashboard, DashboardPart, DashboardBreadcrumbProvider, AccessAdminDashboard, ManageAdminDashboard.Other plugins' skills for the same job