[wp-trac] [WordPress Trac] #10041: like_escape() should escape backslashes too

WordPress Trac wp-trac at lists.automattic.com
Fri Jun 5 11:18:16 GMT 2009


#10041: like_escape() should escape backslashes too
--------------------------+-------------------------------------------------
 Reporter:  miau_jp       |       Owner:            
     Type:  defect (bug)  |      Status:  new       
 Priority:  low           |   Milestone:  Unassigned
Component:  Formatting    |     Version:            
 Severity:  minor         |    Keywords:            
--------------------------+-------------------------------------------------
 The like_escape() function doesn't escape backslashes.

 source:trunk/wp-includes/formatting.php at 11518#L2260
 {{{
         return str_replace(array("%", "_"), array("\\%", "\\_"), $text);
 }}}
 should be ...
 {{{
         return str_replace(array("\\", "%", "_"), array("\\\\", "\\%",
 "\\_"), $text);
 }}}
 or simply ...
 {{{
         return addcslashes($text, '%_');
 }}}

 Considering multi-byte characters ...
 {{{
         if (function_exists('mb_ereg_replace')) {
                 $text = mb_ereg_replace('\\\\', '\\\\', $text);
                 $text = mb_ereg_replace('%', '\\%', $text);
                 $text = mb_ereg_replace('_', '\\_', $text);
                 return $text;
         } else {
                 return addcslashes($text, '%_');
         }
 }}}

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


More information about the wp-trac mailing list