cubecart / v6

CubeCart Version 6
https://cubecart.com
72 stars 59 forks source link

Email content lost on save #3494

Closed abrookbanks closed 1 month ago

abrookbanks commented 6 months ago

The page reloads with no content in the code editor.

bhsmither commented 1 month ago

There is something about this not working correctly. The content from {$CONTENT.content_html|escape:'quotes'} is appearing below the editor box.

bhsmither commented 1 month ago

Try this for near lines 131 and 217:

<input type="hidden" name="template[content_html]" id="template_content_html" class="textbox" value='{$TEMPLATE.content_html|escape:'quotes'}'>

The value of the value property is enclosed in single-quotes.

bhsmither commented 1 month ago

But now, when using apostrophes in the content and saving, extraneous content comes back below the editor window.

bhsmither commented 1 month ago

This is what I did on lines 139 and 225:

editor.getSession().on("change", function () { input.value = editor.getSession().getValue().replace(/'/g,"&#39;"); });

but this changes all apostrophes - including tags' single-quoted property values.

Ugh!

abrookbanks commented 1 month ago

We could go back to the base64 decode and encode method.

<input type="hidden" name="template[content_html]" id="template_content_html" class="textbox" value='{base64-encode($TEMPLATE.content_html)}'>
editor.getSession().on("change", function () { input.value = atob(editor.getSession().getValue()); });
abrookbanks commented 1 month ago

I got it working using this: https://stackoverflow.com/questions/30106476/using-javascripts-atob-to-decode-base64-doesnt-properly-decode-utf-8-strings

abrookbanks commented 1 month ago

Content from input.value instead of feeding in raw value with last commit.

abrookbanks commented 1 month ago

I'm closing this because I'm confident we have a good solution. (Until you tell me otherwise - LOL)

I wanted to use pure the pure atob function but encountered encoding issues. The function b64EncodeUnicode seemed to work well.