A value is written out as raw HTML with Html.Raw, HtmlString or MarkupString, without encoding
What it finds
Html.Raw(x), new HtmlString(x) and (MarkupString)x tell Razor and Blazor that x is safe markup and must not be encoded. If x contains anything that came from a user, its script runs in the page. The rule reports these where the value is not a literal.
From the rule's source, raw_html_from_value.rs.
using Microsoft.AspNetCore.Html; class Widgets{ object Show(string bio) => new HtmlString(bio);tx0 reports: a value is written as raw HTML without encoding object Fixed() => new HtmlString("<br/>");} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:raw-html-from-value" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:raw-html-from-value] reason="..."tx0 explain tx0/csharp:raw-html-from-value shows the same in the terminal. Found a false positive? Report it.