[wp-trac] [WordPress Trac] #33840: wpautop damages inline script
WordPress Trac
noreply at wordpress.org
Sat Sep 12 10:54:22 UTC 2015
#33840: wpautop damages inline script
--------------------------+-----------------------------
Reporter: opajaap | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.3
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
This code:
{{{
$str = '
<script type="text/javascript">
alert( \'<div style="float:right; margin-right:6px;" >Edit</div><div
style="float:right; margin-right:6px;" >Delete</div>\' );
</script>';
echo $str;
echo '<br/>';
echo wpautop($str);
}}}
results in this output as seen in the page source:
{{{
<script type="text/javascript">
alert( '<div style="float:right; margin-right:6px;" >Edit</div><div
style="float:right; margin-right:6px;" >Delete</div>' );
</script><br/><p><script type="text/javascript">
alert( '
<div style="float:right; margin-right:6px;" >Edit</div>
<div style="float:right; margin-right:6px;" >Delete</div>
<p>' );
</script></p>
}}}
The wpautop filter adds {{{<p>}}} twice and {{{</p>}}} once; adds
linebreaks and hence a js error: SyntaxError: unterminated string literal
To my opinion, wpautop should NEVER change a byte between {{{<script>}}}
and {{{</script>}}}; neither should the script tag be wrapped in a p tag.
Wrapping the code in a {{{[CDATA[ ]]}}} block makes no difference.
This behaviour is noticed for years and is still present at version
4.4-alpha-34061
--
Ticket URL: <https://core.trac.wordpress.org/ticket/33840>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list