PiranhaCMS / piranha.core

Piranha CMS is the friendly editor-focused CMS for .NET that can be used both as an integrated CMS or as a headless API.

Home Page:http://piranhacms.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Raw HTML Cant't Save Twitter Embedded View

kttary opened this issue · comments

I created a rawhtml modul and work perfectly on some html code but twitter embedd view, specifically when saving the page. The error message from console is:
error: SyntaxError: Unexpected token '<', "<html><hea"... is not valid JSON

Here is twitter embedded code:
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Our Web <a href="https://twitter.com/hashtag/AntiVirus?src=hash&amp;ref_src=twsrc%5Etfw">#AntiVirus</a> blocked 100M+ unique malicious objects in 2022.<br><br>See how well we fared against <a href="https://twitter.com/hashtag/ransomware?src=hash&amp;ref_src=twsrc%5Etfw">#ransomware</a> <a href="https://twitter.com/hashtag/Trojan?src=hash&amp;ref_src=twsrc%5Etfw">#Trojan</a> bankers &amp; more 👇<a href="https://t.co/PNVYzYMcO6">https://t.co/PNVYzYMcO6</a></p>&mdash; Kaspersky (@kaspersky) <a href="https://twitter.com/kaspersky/status/1600629849424543745?ref_src=twsrc%5Etfw">December 7, 2022</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

any advice on this?

I’m guessing you are not escaping the html in any way when it’s added to the model which in turn causes the JSON to break when it’s posted back to the server.

commented

I'm trying to understand about escaping html. Here is my block definition:

using Piranha.Extend;
using Piranha.Extend.Blocks;

[BlockType(Name = "RawHtml", Category = "Content", Icon = "fab fa-html5")]
public class RawHtmlBlock : TextBlock
{
}

and the cshtml file:

@model RawHtmlBlock

@Html.Raw(Model)