Experience Editor error strikes again!

An error occurred. [Log message: After parsing a value an unexpected character was encountered: {. Path ‘scLayout’

Victory is Fleeting

A couple of months ago I wrote a blog post about how to solve a pesky Experience Editor error that was cropping up when trying to save a page after opening the Rendering Parameter properties dialog for a component. Everything was peachy and calm for a while…until a co-worker contacted me for help because she was seeing the same error. This time, my fix did not resolve it.

shocked cat

The Bug

After editing an Image field of a component’s Rendering Parameters, and attempting to save, we see the familiar error: An error occurred. [Log message: After parsing a value an unexpected character was encountered: {. Path ‘scLayout’

screenshot of experience editor with sitecore error

I noticed that, this time, the error was originating in server-side code, whereas in previous cases it had been thrown by client-side JavaScript.

developer debugger tools

Since the error was happening in a Sitecore class, I attempted to recreate it in a vanilla installation of Sitecore 8.2 (update 1), which was successful (I know: it’s weird to call an error a “success”).

The Patch

I opened a support ticked with Sitecore and they quickly provided a patch for the bug: https://sitecore.app.box.com/s/9bmf6ies5hsc9gbnwds81aokaw1ltfj9

What’s interesting is that the patch includes this change to Website/sitecore/shell/client/Sitecore/ExperienceEditor/ExperienceEditor.js:

sitecore patch code

You’ll notice that they changed usage of unescape() to decodeURIComponent(). It’s interesting because this code used to use decodeURIComponent(), and somewhere during the 8.0 and 8.1 days while they were trying to figure out the client-side version of this error, they changed it to unescape(). I noticed it when I was doing debugging for the previous post because the unescape() function is marked as deprecated. I wondered if there was some clever/obscure reason for using it, but I guess not.

Anyway, here are the 2 functions changed with Support Patch 131168 in Website/sitecore/shell/client/Sitecore/ExperienceEditor/ExperienceEditor.js. (The patch also contains a dll so don’t forget to drop that into your /bin folder!) This code also fixes the error from the previous blog post.

postServerRequest: function (requestType, commandContext, handler, async) {
    var token = $('input[name="__RequestVerificationToken"]').val();
        url: "/-/speak/request/v1/expeditor/" + requestType,
        data: {
            __RequestVerificationToken: token,
            //data: unescape(JSON.stringify(commandContext)) 
            data: decodeURIComponent(JSON.stringify(commandContext))
        success: handler,
        type: "POST",
        async: async != undefined ? async : false
encodeHtml: function (htmlSource) {
    htmlSource = htmlSource.replace(/\\/g, '\\\\').replace(/\"/g, "\\\"").replace(/&/g, "&");
    var encodedHtml = encodeURIComponent(htmlSource);
    return encodedHtml;

    // return jQuery('<div/>').text(htmlSource).html();

I hope this is helpful to some of you. I also hope this is the last post I’m compelled to write about this error!

Add a Comment

Your email address will not be published. Required fields are marked *

Or request call back