Skip Navigation

[Resolved] FORMS/CRED: Saving destroys apostrophes in JS (” / ‘) adds infinite backslashes

This thread is resolved. Here is a description of the problem and solution.

Problem:
The issue here is that the formatting of the user's js script is being destroyed when added to a Toolset form JS editor.

Solution:

This is a known issue and we have an errata setup for this.

https://toolset.com/errata/quotes-in-the-extra-css-or-js-content-will-get-backslashed/

0% of people find this useful.

This support ticket is created 6 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 7 replies, has 2 voices.

Last updated by KonstantinS88 6 years, 3 months ago.

Assisted by: Shane.

Author
Posts
#978374

Whenever I add JS code within a CRED/FORMS form upon saving there are backslashes added to any apostrophe within the sourcecode. The code breaks and looks weird. This happens on all sites in the newest plugin versions:

Example:

jQuery(\\\\\\\"input[name=\\\\\\\'post_title\\\\\\\']\\\\\\\").limiter(160, elem);
#988233

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Konstantinos,

Thank you for contacting our support forum.

Does happen as soon as you save the CRED form ?

Could you send me an example of the code that you are using?

Thanks,
Shane

#988920

Yes it happens upon saving, on all servers I use Tolset on. Never seen this before.

<b>Example:</b>

jQuery(document).ready(function($){
  $("select[name='wpcf-anrede'] option[value='']").text('Anrede');   
});

After saving it turns into:

jQuery(document).ready(function($){
  $(\"select[name=\'wpcf-anrede\'] option[value=\'\']\").text(\'Anrede\');   
});

And then into:

jQuery(document).ready(function($){
  $(\\\"select[name=\\\'wpcf-anrede\\\'] option[value=\\\'\\\']\\\").text(\\\'Anrede\\\');   
});

Etc. etc. etc.

#995151

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Konstantinos,

I was able to replicate the issue and escalated it to our 2nd tier supporters for further debugging.

Thanks,
Shane

#1017259

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Konstantinos,

We actually have a patch about this one.
https://toolset.com/errata/quotes-in-the-extra-css-or-js-content-will-get-backslashed/

Please try this and let me know if it helps.
Thanks,
Shane

#1034147

You are awesome. The fix works like a charm.

#1081339

Just FYI: The newest Forms Version did not include this fix, had to upload it onto my sites maually again...

#1081346
broken.JPG

It does not work anymore - at least not with the latest Forms version. It is even worse:

The backend shows the code properly but in the source the code is still broken.