Declined
Last Updated: 26 Apr 2022 04:55 by ADMIN
IneqeDevTeam
Created on: 21 Apr 2022 15:57
Category: Editor
Type: Bug Report
0
Blazor Editor: Empty "src" attributes causing JavaScript exception

Hi,

We are using the Blazor Editor for a feature in one of our web apps, and created a custom tool for the editor that allows the user to modify the raw HTML.

If an IFrame is added to the HTML with an empty or missing "src" attribute like so:

<iframe src=""></iframe>

OR

<iframe></iframe>

The editor will throw a JS Interop exception:

No value supplied for attribute src
      OP@https://[redacted]/_content/Telerik.UI.for.Blazor/js/telerik-blazor.js:6:830821
      PP.prototype.computeAttrs

Would you guys consider this a bug with the editor? Since they are technically valid elements, mganss' HtmlSanitizer does not remove sourceless IFrames and unfortunately there does not seem to be a way to make it do so.

Thanks in advance for the assistance!

3 comments
ADMIN
Dimo
Posted on: 26 Apr 2022 04:55

Hi Michael,

Thanks for the follow-up. Based on the provided information, I will close this bug report, but anyone can provide additional comments, if necessary.

Regards,
Dimo
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

IneqeDevTeam
Posted on: 22 Apr 2022 11:57

Hi Dimo

 

Thanks for the assistance. As you pointed out, the built-in View HTML tool does not have the issue. A custom implementation is needed in our case, however, due to some additional requirements.

After some thought I believe the issue is more on our side since the custom implementation is working outside the bounds of the Telerik Blazor Editor somewhat. The best solution would probably be using a HTML parser to remove sourceless IFrames when the "Update HTML" button is clicked.

 

Kind regards

Michael

ADMIN
Dimo
Posted on: 21 Apr 2022 17:38

Hello,

Indeed, the iframe src attribute is required by design. At the same time, I was unable to reproduce the error. I tested with programmatic insertion and manual editing of the HTML value via the respective built-in tool.

Does "about:blank" work for you?

@using Telerik.Blazor.Components.Editor

<TelerikButton OnClick="@InsertIframe">Insert IFRAME</TelerikButton>

<TelerikEditor @ref="@EditorRef" @bind-Value="@TheContent" Tools="@EditorTools" />

@code{
    TelerikEditor EditorRef { get; set; }
    List<IEditorTool> EditorTools { get; set; } = new List<IEditorTool>() { new ViewHtml() };

    string TheContent { get; set; } = "<p>Lorem ipsum.</p><p>Dolor sit amet.</p>";

    async Task InsertIframe()
    {
        await EditorRef.ExecuteAsync(new HtmlCommandArgs("insertHtml", @"<iframe src=""about:blank""></iframe>"));
    }
}

Regards,
Dimo
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.