The Problem
We are on Sitecore 10.1 update 2. We had a business requirement to allow HTML tags in single-line text fields so that page headings and subheadings can have superscripts etc. in them. We understand that for security reasons, Sitecore encodes all the HTML tags entered into the fields. This needed us to make sure to add logics in our backend to ensure that the HTML tags gets decoded so that they can be rendered at the front end. So far so good and everything went as planned. After the customization, we were able to see the HTML tags added to single-line text fields getting rendered properly at front-end.
Then where is the problem?
We did a few more edits on the page and observed that HTML tags added to Single-Line text fields earlier got stripped off during subsequent edits and page saves. Here is a video of the issue -
The Research
This issue was also reproducible on sandbox instances. This proved that it was not due to any of the customizations done in our solution. We reached out to Sitecore Support and after analysis, they reported that this is in fact a bug in Sitecore with reference number - 520726. It has been fixed in latest versions i.e. Sitecore 10.3. The only solution Sitecore has for us at this point for this problem is to upgrade to Sitecore 10.1.3 pre-release or do a customization on your own.
One of the reason why Sitecore has started to use pre-release as the hotfix, is to avoid conflict when another hotfix requested in the future, where unexpected behavior can occur if conflicts happen, resulting to a bigger issue.
We can not move to a pre-release or latest release of Sitecore at this point as it requires bigger effort than developing the customization. We have found that the HTML tags get stripped mainly due to the Sitecore.ExperienceEditor.Utils.WebUtility.GetFields(). Below highlighted lines of code can be added to make it work -
Well, it is a lot of work and I really hope Sitecore provided a hotfix for this issue. At this point, we are implementing this change and will keep you updated how it goes.
Update 1 - We did find that all the processors that make use of GetSaveArgs() and GetControlsToValidate() also need to be overridden to make use of updated GetSaveArgs() and GetControlsToValidate() which use customized GetFields(). So this left us updating 7 processors to fix this bug. PHEWWW!!
Thanks for reading. Hope it helped you!
Comments
Post a Comment