Square bracket in custom code replaced with HTML entity after update

Hello! Something with a recent update has broken a number of pages with custom code that have been up for years. I’ve narrowed it down that it is something to do with having a second “fail gracefully” section that displays a picture for users who are on mobile. When this section exists, for some reason WordPress replaces square brackets in the custom code with their HTML entities. Example below:

When the “fail gracefully” section exists (see this page) it throws an Uncaught SyntaxError: Unexpected token '&' error because wordpress replaces square brackets in this line:

>     var x2 = d3.scaleTime()
>                    .domain([new Date(2017,9,1), new Date(2018,8,29)])
>                    .rangeRound([0, width]);

When the “fail gracefully” section is removed (see this test page)
) the custom code works as intended because WordPress does not replace the brackets in the same line:

> var x2 = d3.scaleTime()
>            .domain([new Date(2017,9,1), new Date(2018,8,29)])
>            .rangeRound([0, width]);

Any ideas on why having a second section would be doing this replacement? Ideally I would like to keep the “fail gracefully” section, and they have worked together without issues in the past. I understand if custom code is outside of scope for support, but I appreciate any insight you might have!

Thank you!

Hey @campkels,

It looks like you added your custom JS outside of the Global JS nor Cornerstone’s Page JS. This means that the issue is the coding itself so regretfully, we can’t provide assistance.

Please consult with a 3rd party developer to resolve your issue.

Thank you for understanding.

Ok, I understand. Just the weirdest thing that a second Cornerstone section would alter the code in another section all of a sudden! So curious what changed in the update!

Thanks again.

Hello @campkels,

Just use the Raw content element and make sure that the HTML code is valid and correct. The apostrophe, commas and other character must be correct and not in HTML characters.

Best Regards.

Turns out if I delete the section and add the same content back in as a row in the original section with the raw content, it doesn’t do the replacement! Still makes no sense but thought I would share in case there is someone else having issues!

Thank you!

Hi @campkels,

Thanks for sharing to help others.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.