Aspnetcore: 0.5.0 is decoding HTML entities

Created on 26 Jul 2018  路  7Comments  路  Source: dotnet/aspnetcore

I have angle bracket HTML entities in a Blazor client-side app page ...

<h1 style="font-style:@@_headingFontStyle">@@_headingText</h1>

... it would render that content out with the encoded angle brackets. The browser would render that as text ...

<h1 style="font-style:@_headingFontStyle">@_headingText</h1>

I just did an 0.4.0 -> 0.5.0 update. It's apparently decoding those &lt; and &gt; into actual angle brackets. The browser is now rendering that content as HTML.

capture

area-blazor

Most helpful comment

@guardrex following workaround works:
@((MarkupString)"<code>invokeAsync&lt;object&gt;</code> to invoke..")

All 7 comments

Confirmed, just found the same thing when I upgraded my project BlazorChatSample to 0.5.0.

Source: https://github.com/conficient/BlazorChatSample/blob/master/BlazorChatSample.Client/Pages/Index.cshtml this has <code>invokeAsync&lt;object&gt;</code> to invoke.. in the HTML but on the browser is rendered as

<code>invokeAsync<object> to invoke .... <p></p>

See https://blazorchatsample.azurewebsites.net/ for example

&#x0003C;h1 style="font-style:@@_headingFontStyle"&#x0003E;@@_headingText&#x0003C;/h1&#x0003E;
&#60;h1 style="font-style:@@_headingFontStyle"&#62;@@_headingText&#60;/h1&#62;

... lead to the same result.

@danroth27 @SteveSandersonMS I can update the "Build your first" experience sample app (it doesn't use HTML entities), but I can't easily update the doc's "Common" sample app to 0.5.0 until this is resolved or I go with images as a workaround. The content explains what the sample code is doing, and I don't want to lose that presentation. If this will take a while to fix, then what I'll probably do is screenshot the 0.4.0 app's output and use images in the sample. Since that's a time-consuming workaround, I'll wait until I hear back from you on this before I proceed.

Thanks for the report! And sorry for the inconvenience.

The earliest we could feasibly fix this would be in a 0.5.1 update possibly next week but more likely the week after.

@SteveSandersonMS Thanks --- I think the best I can do today is just screenshot the markup I want to show and load some images into the pages. I could just kill the content temporarily, but I feel that showing the markup is an important educational component of the sample. I'll open a docs issue and keep an :eye: out for 0.5.1.

@guardrex following workaround works:
@((MarkupString)"<code>invokeAsync&lt;object&gt;</code> to invoke..")

@Suchiman Perfect! Thank you. I'll do that until the patch lands.

Fixed with 8c452ff71ad1c59af0115747794a313d91ace789

We'll apply a more long-term fix when we reintroduce the markup optimization later.

Was this page helpful?
0 / 5 - 0 ratings