[wp-trac] [WordPress Trac] #7648: js_escape() wrongly escapes too many characters

WordPress Trac wp-trac at lists.automattic.com
Sat Aug 30 08:27:00 GMT 2008


#7648: js_escape() wrongly escapes too many characters
--------------------------+-------------------------------------------------
 Reporter:  Viper007Bond  |       Owner:  anonymous
     Type:  defect        |      Status:  new      
 Priority:  normal        |   Milestone:  2.7      
Component:  General       |     Version:  2.6.1    
 Severity:  normal        |    Keywords:  has-patch
--------------------------+-------------------------------------------------
 Using `js_escape()`, there is no way to output `<`, `>`, or `"` as they
 are converted to HTML entities.

 Example:

 {{{
 <script type="text/javascript">
 <?php
 echo 'alert("' . js_escape('HTML \'for\' "bold": <strong>bold
 text!</strong>') . '");';
 ?>
 </script>
 }}}

 This is the output:

 {{{
 alert("HTML \'for\' &quot;bold&quot;: &lt;strong&gt;bold
 text!&lt;/strong&gt;");
 }}}

 Rather than this as expected:

 {{{
 alert("HTML \'for\' \"bold\": <strong>bold text!</strong>");
 }}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/7648>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list