[wp-trac] [WordPress Trac] #4738: js_escape eats baslash escaped characters

WordPress Trac wp-trac at lists.automattic.com
Mon Aug 13 14:01:21 GMT 2007

#4738: js_escape eats baslash escaped characters
 Reporter:  nbachiyski      |       Owner:  anonymous  
     Type:  defect          |      Status:  new        
 Priority:  normal          |   Milestone:  2.3 (trunk)
Component:  Administration  |     Version:             
 Severity:  normal          |    Keywords:             
 {{{js_escape('\n')}}} gives only {{{n}}} and it should give {{{\n}}}

 The problem is that first {{{stripslashes}}} and then {{{addslashes}}} are
 applied to the string, which doesn't guarantee that the string will remain
 the same.

 Also, I still don't get why {{{js_escape}}} has to do something more than
 replacing {{{'}}} with {{{\'}}}, {{{"}}} with {{{\"}}} and  newline
 characters with {{{\n}}}.  Isn't its only purpose to make sure that the
 given php string is processed without errors by javascript? Why do we use
 {{{wp_specialchars}}}? Why do we put html entities, when we aren't sure
 the javascript code expects those?

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

More information about the wp-trac mailing list