U4-644 - DyanmicNode bug with custom richtext properties on Media items: returns incorrect HTML (from default Examine index) stripped of all tags

Created by Sebastiaan Janssen 19 Aug 2012, 14:55:14 Updated by Shannon Deminick 08 May 2013, 23:28:02

Is duplicated by: U4-1078

Steps to reproduce this bug are documented in the Our forums here { http://our.umbraco.org/forum/developers/razor/31803-Richtext-editor-property-on-a-Media-type-HTML-tags-are-stripped-when-rendered }.

Gareth identified the nature of the problem and summed it up nicely on 2012-07-19 on some other thread I hijacked here { http://our.umbraco.org/forum/developers/razor/24368-DynamicMediaUrl-is-null-in-471?p=2#comment122458 } which I quote below for reference:

Gareth wrote:

Examine is doing this strip intentionally, but it wasn't a problem until recently because when I wrote the DynamicNode feature, the custom properties for media weren't available in the index.

So, it's by design in examine, but a bug in DynamicNode.

This thread, { http://our.umbraco.org/forum/developers/api-questions/17737-Examine-returns-wrong-markup#comment66705 } that I was pointed to on twitter explains the behaviour and how to work around it when you're using your own custom indexer.

Unfortunately, that doesn't help us and this should be raised as a bug in DynamicNode.

I don't know the exact fix here though, it seems that I need to alter the native indexes to have secondary copies of the RTE content that isn't stripped of it's formatting. I am just using the built in examine indexes that ship with Umbraco and I haven't altered them before.


''Originally created on CodePlex by [Funka|http://www.codeplex.com/site/users/view/Funka]'' on 8/7/2012 7:41:40 PM [Codeplex ID: 30983 - Codeplex Votes: 1]

Imported comments

''Comment by [sebastiaan|http://www.codeplex.com/site/users/view/sebastiaan] on 8/8/2012 6:07:29 AM:'' Gareth has posted his questions here: https://groups.google.com/forum/#!topic/umbraco-dev/6J5SN9hXhLg%5B1-25%5D

As a workaround you can of course still do this (but it queries the database, so cache your macro):

@{ var mediaFromDatabase = new umbraco.cms.businesslogic.media.Media(id); } @Html.Raw(mediaFromDatabase.getProperty("description").Value.ToString())

Comments

Funka! 21 Aug 2012, 18:58:17

To further add to this issue, I've today noticed that it is not just richtext HTML properties that are getting stripped; this bug also happens on any XML-storing properties as well, such as a uComponents UrlPicker. (In the meantime, thank you Sebastiaan for the workaround!)


Owen 20 Mar 2013, 11:33:49

I'm using Umbraco 6.02 and this is still happening. The suggested workaround does the job.


Andy Dyton 01 May 2013, 10:34:39

I've also experienced this issue with HTML being stripped from media item properties.

Steps to reproduce:

  • Create a new media type
  • Give it a property that can store HTML (textbox multiple, RTE)
  • Save HTML as the property value
  • Try and retrieve the property value via razor

The value is stored as expected in the database, it's just the retrieval of the value that fails.


Shannon Deminick 07 May 2013, 01:25:47

All fixed in revisions: 79cda04717fa, 1ef8fa3b62ee, 064f5a9589bd for all releasable versions


Funka! 07 May 2013, 18:51:37

Thank you, Shannon, this is wonderful to see! Looking forward to this in 4.11.9!


Mike Chambers 08 May 2013, 12:09:47

does examine now hold both the stripped representation and the full html?


Shannon Deminick 08 May 2013, 23:28:02

@Mike, yeah we are now storing a raw value of the rich text value, or any other value that is detected to be xml or html. The raw value isn't searchable, it is simply stored in the index for data retrieval.


Priority: Normal

Type: Bug

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 4.8.0, 4.9.0, 4.10.0, 4.11.0, 6.0.0, 4.9.1, 4.11.1, 4.11.2, 4.11.3, 4.11.4, 6.0.1, 4.11.5, 6.0.2, 4.11.6, 6.0.3, 6.0.4, 4.11.7

Due in version: 6.1.0, 6.0.6, 4.11.9

Sprint:

Story Points:

Cycle: