WordPress.org

Make WordPress Core

Ticket #22286: 22286.diff

File 22286.diff, 816 bytes (added by SergeyBiryukov, 17 months ago)
  • wordpress/wp-includes/formatting.php

     
    13421342 * @return string String with backslashes inserted. 
    13431343 */ 
    13441344function backslashit($string) { 
    1345         $string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string); 
    1346         $string = preg_replace('/([a-z])/i', '\\\\\1', $string); 
     1345        // string literals are chosen instead of 0x30..0x39 as value selected 
     1346        // from string is more likely to be string, than integer, thus casted 
     1347        // PHP form shall take place 
     1348        if ( isset( $string[0] ) && $string[0] >= '0' && $string[0] <= '9' ) { 
     1349                $string = '\\\\' . $string; 
     1350        } 
     1351        $string = addcslashes( $string, 'A..Za..z' ); 
    13471352        return $string; 
    13481353} 
    13491354