mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-05 02:10:45 +01:00
Make replacement strings backref safe without using \${1} so as to preserve php <= 4.2 compatible. Props mdawaffe. fixes #2774
git-svn-id: http://svn.automattic.com/wordpress/branches/2.0@3856 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c1d27f3113
commit
dacaa7594f
@ -517,10 +517,11 @@ function format_to_post($content) {
|
||||
|
||||
function zeroise($number,$threshold) { // function to add leading zeros when necessary
|
||||
return sprintf('%0'.$threshold.'s', $number);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function backslashit($string) {
|
||||
$string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string);
|
||||
$string = preg_replace('/([a-z])/i', '\\\\\1', $string);
|
||||
return $string;
|
||||
}
|
||||
|
@ -32,10 +32,10 @@ function mysql2date($dateformatstring, $mysqlstring, $translate = true) {
|
||||
$dateweekday = $weekday[date('w', $i)];
|
||||
$dateweekday_abbrev = $weekday_abbrev[$dateweekday];
|
||||
$dateformatstring = ' '.$dateformatstring;
|
||||
$dateformatstring = preg_replace("/([^\\\])D/", "\${1}".backslashit($dateweekday_abbrev), $dateformatstring);
|
||||
$dateformatstring = preg_replace("/([^\\\])F/", "\${1}".backslashit($datemonth), $dateformatstring);
|
||||
$dateformatstring = preg_replace("/([^\\\])l/", "\${1}".backslashit($dateweekday), $dateformatstring);
|
||||
$dateformatstring = preg_replace("/([^\\\])M/", "\${1}".backslashit($datemonth_abbrev), $dateformatstring);
|
||||
$dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
|
||||
$dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring);
|
||||
$dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
|
||||
$dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
|
||||
|
||||
$dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
|
||||
}
|
||||
@ -71,10 +71,10 @@ function date_i18n($dateformatstring, $unixtimestamp) {
|
||||
$dateweekday = $weekday[date('w', $i)];
|
||||
$dateweekday_abbrev = $weekday_abbrev[$dateweekday];
|
||||
$dateformatstring = ' '.$dateformatstring;
|
||||
$dateformatstring = preg_replace("/([^\\\])D/", "\${1}".backslashit($dateweekday_abbrev), $dateformatstring);
|
||||
$dateformatstring = preg_replace("/([^\\\])F/", "\${1}".backslashit($datemonth), $dateformatstring);
|
||||
$dateformatstring = preg_replace("/([^\\\])l/", "\${1}".backslashit($dateweekday), $dateformatstring);
|
||||
$dateformatstring = preg_replace("/([^\\\])M/", "\${1}".backslashit($datemonth_abbrev), $dateformatstring);
|
||||
$dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
|
||||
$dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring);
|
||||
$dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
|
||||
$dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
|
||||
$dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
|
||||
}
|
||||
$j = @date($dateformatstring, $i);
|
||||
|
Loading…
Reference in New Issue
Block a user