-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird (lack of?) Double Escaping of Block List Content when A Contentment Block editor is inside a core Block List. #226
Comments
Sad face emoji. feels like i have escaped / not-escaped / escaped blocks and nested content and grid elements for past 5 years, there is always one way where it doesn't like it. we de-escape everything when we process it, so we can process all the subitems, but putting it back obs in this instance isn't right. This will be a core uSync issue. (its the block list mappers that are not doing things). So i will see what we can do/break/fix. |
I'll try... Just for replicating all the things the project has
and this generates the models to a class library project folder which is included in the Umbraco Project (I know like dot net framework...) Then in your Page Document Type that has the BlockListProperty, you will have at the top Then in your view, this project loops through each of the Blocks...
I'm not sure why it's calling a ViewComponent for each block... something to do with having different themes I think ahh yes, the ContentBlock ViewComponent does this: so it looks for a themed View
So for each block it renders a View, so for this Accordion Block it's like this
where you can see the check to see if it has child items and it renders the third level... You can see in the HTML of the page that
is rendered ok so it is this reading of whether the nested item has nested items that is the issue... if that helps... I'm not sure if this is the correct 'modelsbuilder' way, I didn't write it, but basically Modelsbuilder should give you a strongly typed property for each nested property, that you can foreach through... hmmm, wonder if issue is in modelsbuilder then if it works with StringlyTypedModels? |
Works for me 😞 i have this view : @using Umbraco.Cms.Web.Common.PublishedModels;
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.BlockPage>
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
@{
Layout = null;
<h1>@Model.PageTitle</h1>
@foreach(var block in Model.Blocks)
{
RenderBlock((ContentModels.BlockTypeOne)block.Content);
}
}
@{
void RenderBlock(ContentModels.BlockTypeOne block) {
<h2>@block.PageTitle</h2>
<div>
@block.BlockContent
</div>
<div>
@foreach(var child in block.Blocks) {
RenderBlock((ContentModels.BlockTypeOne)child.Content);
}
</div>
}
} tripple nested list content, pushed between two servers (on to a blank new install, not config changes (so InMemory models builder?). renders this: |
I wonder if there is something with the specific content then... or in this slightly elaborate approach, I'll try putting a basic loop through the properties as you have to see tomorrow... but we has spent a few hours coming to this conclusion :-( so sad face emoji if issue is in the code! |
Aha! curveball, Of course, the Inner Block is using ContentBlocks! of course you'd have Block list on the outside, but Contentment Content blocks on the inside... doh (if only Lee made it clear somehow in the backoffice) Ok soooooooooo the Property Value Converter for Contentment Blocks has this
When Umbraco publishes the page it is a 'string', but when uSync publishes it, it's a JArray that comes into the property value converter and so the Contentment Blocks Property Value Converter 'skips it'... sigh...
but my guess must be it's an issue in ContentmentContentBlocks mapper? But I can't see how! why the stored value pushed by uSync would be considered a JArray and not a string? Unless your cleaning of the escaping makes it a valid JArray, but the Umbraco Save and Publish adds lots of escaping and it's no longer a valid JArray and so is determined to be a string instead... |
Ahhh Soo I had conversations with Lee a long time ago about Contentment Content blocks and escaping (or the lack off) and how it worked in the Backoffice and then not on the site. and we did something (it was a long time ago). So i suspect that is why the code does something odd, and why we are playing the is it a JArray card. I will have to look back and see what if anything i can recall about why we did what we did. |
Describe the bug
When a Block List is used inside a Block List (I know how awful)
the inner block list needs to be 'double escaped', because it's JSON inside JSON
And if you have a Block List within that Block List within a Block List
You need it to be 'triple escaped'
What we are seeing is that for an Editor that has this lovely triple depth of nesting is that Umbraco saves the content to the database in this triple escaped fashion and all renders ok on the front end...
but when we publish this page to another server via uSync Complete
Then the JSON stored in the database for the item is no longer Triple Escaped...
But, and this is the weird thing, if you open up the page in the backoffice on the instance that has been published to, the backoffice shows all the nested block lists, with all the content at each level intact!
Isn't that bloody brilliant?
But, on the front end, when you use Modelsbuilder to write out the nested blocks, looping through each level it can't work out the nested blocks, because the lack of escaping, and so you don't see any child blocks when looping through them, literally they are not there.
When you press Save and Publish in the backoffice, then Umbraco updates the saved data in the database entry to have the triple level of escaping and Modelsbuilder is happy to deserialise again, and show the blocks.
Here is a screenshot showing, how uSync has sent the data on top, and how Umbraco has stored it in the first place and what it gets changed to when you press save and publish - see the extra \\\\\\\\\\\\\\\\
But if you were only ever looking in the backoffice you'd never know that it hadn't worked as expected!
Version (please complete the following information):
To Reproduce
Steps to reproduce the behavior:
Create a Block List Property Editor on a Page
Allow within that another Block List of Repeating Items
And allow that to have a Block List that adds further blocks...
Write a View that loops through each level of blocks writing out the content.
Now fill in content for these blocks - save and publish, see how each level is saved in db with multiple levels of escaped-ness
See how the nested content blocks are written out in the view.
then push this using uSync Complete to another environment
see in the backoffice of your 'production environment' that the nested blocks have been pushed successfully
then look at the front end of the site and stare in disappointment that only the top level blocks have been rendered
Look in database to see how the saved content no longer has the multi levels of escaped-ness
Save and publish the page in production, marvel how the view now writes out the nested block content
and see in the database how this updated version now has multi levels of escaped-ness...
Expected behavior
I think I'd expect uSync to persist the multi-level of escaped-ness
so when you publish the page in staging, it updates in production, without having to save and publish it in production to correct.
Screenshots
Another screenshot...
At least it's not nested block list within nested block list within nexted block list within vorto!
The text was updated successfully, but these errors were encountered: