-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected encoding of ampersand (&) to & #11789
Comments
I am also facing exactly the same issue. Any fix/alternative for this ? |
I found a workaround. It is to extract the JavaScript code into its own file. In PHP, you load that file and call a function to trigger the code. Its not a solution though - there is a true bug that needs to be fixed. And to @designsimply this is not a help request - this is a bug report. |
Thanks @martindrapeau , |
Gotcha! I've fixed the label and send my apologies for the mistake! |
change condition orders. For instant if your condition is like this: ( x<y && z>w) replace with (z>w && x<y) |
Hi @martindrapeau and others. |
Just ran into this issue again with the latest version of wordpress (5.7). |
Hi @godismyjudge95 Daniel. I added the question into the Slack core editor channel to hear if this method is (still) valid. |
@paaljoachim I meant to mention, this also happens with just the plain Custom HTML block. So it must be something with the HTML parser. Another thing that might help narrow it down, the javascript appears to work in the HTML preview of the block. So maybe it is the save/retrieve functions that is malfunctioning? |
This should be completely independent from the
<script>
if (true && true) alert('ok')
</script> |
Try this case
|
@dancodedev: thanks, that was helpful. I've tracked this down to a bug in
|
I've added a comment under the original issue to describe this particular case. Closing as a duplicate of t45387. |
Still happening in Wordpress 2023. I inverted my logic
became
since only & is affected 🤷♂️ |
I have registered a dynamic block and use a PHP function to generate some script tags and inline JavaScript. The JavaScript code gets modified upon output - some of the & get url encoded to &. The JavaScript interpretation then errors out.
This same code is being used by shortcodes with no url encoding (as expected).
The odd thing is that not all & get url encoded (see yellow underlined lines 117 or 118).
To Reproduce
You can view the broken JavaScript on this test page (generated from dynamic block): https://lab.amilia.com/gutenberg-bug/
You can view the working JavaScript on this test page (generated by shortcode): https://lab.amilia.com/plugin-calendar/
The source code for the plugin is here:
Block registration: https://plugins.trac.wordpress.org/browser/amilia-store/trunk/blocks/amilia-store-calendar.php
PHP back-end rendering function: https://plugins.trac.wordpress.org/browser/amilia-store/trunk/shortcodes/amilia-store-calendar.php
Desktop
The text was updated successfully, but these errors were encountered: