I changed the display name of an item from Item1 to (This is the new title)
However, in the tree, while the closing ) shows up, the opening appears encoded. It shows as:
(This is the new title)
How do I fix this please?
This is a known bug, introduced in 9.3 iirc. Reference number 393368. As far as I'm aware, there isn't a patch yet for it, but you can patch it yourself by replacing the faulty pipeline.
Look at Sitecore.Pipelines.Save.Save
class in Sitecore.Kernel
. In the deep nested Process()
method, you'll see this code (reflected with dotPeek):
if (this.NeedsHtmlTagEncode(field1))
field1.Value = WebUtil.SafeEncode(field1.Value);
The NeedsHtmlTagEncode
returns true for DisplayName
(for some unknown reason). You can workaround this issue by replacing the Save processor with one that inherits the old one and overrides the protected virtual bool NeedsHtmlTagEncode(SaveArgs.SaveField field)
method and just let it return false. Then you just patch out the existing processor with your own one with the xpath /sitecore/processors/saveUI/processor[@type='Sitecore.Pipelines.Save.Save, Sitecore.Kernel']
.
An update since we just encountered this in one of our projects:
In addition to the bug mikaelnet wrote about, which affects when you change the Display name field in the Content Editor Appearance
section and then save the item, there is a second bug that affects the Display name ribbon menu button you are using here.
From what I found, the problem is in the /sitecore/shell/Applications/Dialogs/Prompt/prompt.js
file and was introduced some time between 9.0 and 9.3.
This is the 9.0 version:
function ok_click(evt) {
evt && Event.stop(evt);
var maxlength = (dialogArguments.maxLength != null ? parseInt(dialogArguments.maxLength, 10) : 0);
if (dialogArguments.validation != null) {
var re = new RegExp(dialogArguments.validation);
}
var result = $("Value").value;
...
The 9.3 version has an added sanitizeHtml
call:
function ok_click(evt) {
evt && Event.stop(evt);
var maxlength = (dialogArguments.maxLength != null ? parseInt(dialogArguments.maxLength, 10) : 0);
if (dialogArguments.validation != null) {
var re = new RegExp(dialogArguments.validation);
}
var result = sanitizeHtml($("Value").value);
...
I believe both issues were reported in the mentioned bug and we have seen a patched version of the sanitizeHtml()
method that fixes some encoding issues, but I don't see why they would encode the result in the first place so the underlying issue you are seeing is still there.