Skip to content

Commit

Permalink
Update Rule “do-you-know-how-to-render-html-strings/rule” (#6220)
Browse files Browse the repository at this point in the history
  • Loading branch information
cvionnet authored Aug 2, 2023
1 parent f56e56d commit 1133ebd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rules/do-you-know-how-to-render-html-strings/rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ This is to prevent double encoding, which can distort the original HTML content
```cs
string message = "Hello, <b>world</b>!";

Output: <p>Hello, &lt;b&gt;world&lt;/b&gt;!</p>
Output: Hello, &lt;b&gt;world&lt;/b&gt;!
```
::: bad
Figure: Bad example - HTML tags using a string have been HTML encoded
Figure: Bad example - A string containing HTML tags will be encoded
:::

```cs
IHtmlContent message = new HtmlString("Hello, <b>world</b>!");

Output: <p>Hello, <b>world</b>!</p>
Output: Hello, <b>world</b>!
```
::: good
Figure: Good example - HTML tags using IHtmlContent have been treated as safe HTML and not encoded
Figure: Good example - HTML tags using IHtmlContent will be treated as safe HTML and not encoded
:::

::: info
Expand Down

0 comments on commit 1133ebd

Please sign in to comment.