Skip to content

Component attribute values don't decode HTML entities #42

Closed

Description

@Shewart

Summary

Attribute values on components written in Markdown are passed through as written, so HTML entities show up literally.

Steps to reproduce

<Callout Title="Tom &amp; Jerry" Text="Use &lt;Tabs&gt; for this." />

Expected: the callout reads "Tom & Jerry" and "Use for this."
Actual: the entities show literally: Tom &amp; Jerry and Use &lt;Tabs&gt; for this. (Blazor escapes the value as text).

Where

src/ShellDocs.Markdown/RazorTagScanner.cs (attribute values) and SlotExtractor / PreviewParser, which turn them into component parameters.

Suggested fix

WebUtility.HtmlDecode string attribute values (not @(...) expressions) before they become parameters. Add tests for &amp;, &lt;, &quot; and numeric entities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions