Opened 9 years ago
Last modified 6 years ago
#33840 new defect (bug)
wpautop damages inline script
Reported by: | opajaap | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.3 |
Component: | Formatting | Keywords: | wpautop |
Focuses: | Cc: |
Description
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
Change History (2)
Note: See
TracTickets for help on using
tickets.
Need to check this ticket for versioning and duplicates.