[wp-trac] [WordPress Trac] #44571: force_balance_tags breaks JavaScript
WordPress Trac
noreply at wordpress.org
Wed Jul 11 21:11:07 UTC 2018
#44571: force_balance_tags breaks JavaScript
-----------------------------+-----------------------------
Reporter: yellowafterlife | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Shortcodes | Version: 4.9.7
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
Input:
{{{
<?php
echo force_balance_tags('<script>console.log("extest:", 0<=1);</script>')
?>
}}}
Output:
{{{
<script>console.log("extest:", 0< =1);</script></script>
}}}
(no longer valid JavaScript)
Context:
I use tiny (<20KB) JS programs for interactive illustrations inside
tutorials on a WP blog. These would most commonly break on pages where
excerpts are shown (post list, search) and it took a little while to
narrow this down to force_balance_tags running for !--more splitter in
get_the_content.
Workarounds: enclosing JS code in a comment
{{{
<script><!-- code --></script>
}}}
which is a legacy part of spec
https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-
contents-of-script-elements
Could the script-tags be treated like the comments in this regard? This is
a rather unobvious behaviour.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44571>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list