Make WordPress Core

Changeset 3856


Ignore:
Timestamp:
06/08/2006 03:21:04 AM (18 years ago)
Author:
ryan
Message:

Make replacement strings backref safe without using \${1} so as to preserve php <= 4.2 compatible. Props mdawaffe. fixes #2774

Location:
branches/2.0/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/wp-includes/functions-formatting.php

    r3794 r3856  
    518518function zeroise($number,$threshold) { // function to add leading zeros when necessary
    519519    return sprintf('%0'.$threshold.'s', $number);
    520     }
     520}
    521521
    522522
    523523function backslashit($string) {
     524    $string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string);
    524525    $string = preg_replace('/([a-z])/i', '\\\\\1', $string);
    525526    return $string;
  • branches/2.0/wp-includes/functions.php

    r3841 r3856  
    3333        $dateweekday_abbrev = $weekday_abbrev[$dateweekday];
    3434        $dateformatstring = ' '.$dateformatstring;
    35         $dateformatstring = preg_replace("/([^\\\])D/", "\${1}".backslashit($dateweekday_abbrev), $dateformatstring);
    36         $dateformatstring = preg_replace("/([^\\\])F/", "\${1}".backslashit($datemonth), $dateformatstring);
    37         $dateformatstring = preg_replace("/([^\\\])l/", "\${1}".backslashit($dateweekday), $dateformatstring);
    38         $dateformatstring = preg_replace("/([^\\\])M/", "\${1}".backslashit($datemonth_abbrev), $dateformatstring);
     35        $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
     36        $dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring);
     37        $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
     38        $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
    3939
    4040        $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
     
    7272        $dateweekday_abbrev = $weekday_abbrev[$dateweekday];
    7373        $dateformatstring = ' '.$dateformatstring;
    74         $dateformatstring = preg_replace("/([^\\\])D/", "\${1}".backslashit($dateweekday_abbrev), $dateformatstring);
    75         $dateformatstring = preg_replace("/([^\\\])F/", "\${1}".backslashit($datemonth), $dateformatstring);
    76         $dateformatstring = preg_replace("/([^\\\])l/", "\${1}".backslashit($dateweekday), $dateformatstring);
    77         $dateformatstring = preg_replace("/([^\\\])M/", "\${1}".backslashit($datemonth_abbrev), $dateformatstring);
     74        $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
     75        $dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring);
     76        $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
     77        $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
    7878        $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
    7979    }
Note: See TracChangeset for help on using the changeset viewer.