mirror of
git://develop.git.wordpress.org/
synced 2025-01-18 05:18:42 +01:00
Catch NULL, bool, and integer values in is_serialized(). Props mdawaffe. fixes #3310
git-svn-id: https://develop.svn.wordpress.org/trunk@4438 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4e20befc81
commit
5ae75c9a44
@ -163,19 +163,37 @@ function maybe_unserialize($original) {
|
||||
}
|
||||
|
||||
function is_serialized($data) {
|
||||
if ( !is_string($data) ) // if it isn't a string, it isn't serialized
|
||||
// if it isn't a string, it isn't serialized
|
||||
if ( !is_string($data) )
|
||||
return false;
|
||||
$data = trim($data);
|
||||
if ( preg_match("/^[adobis]:[0-9]+:.*[;}]/si",$data) ) // this should fetch all legitimately serialized data
|
||||
if ( 'N;' == $data )
|
||||
return true;
|
||||
if ( !preg_match('/^([adObis]):/', $data, $badions) )
|
||||
return false;
|
||||
switch ( $badions[1] ) :
|
||||
case 'a' :
|
||||
case 'O' :
|
||||
case 's' :
|
||||
if ( preg_match("/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data) )
|
||||
return true;
|
||||
break;
|
||||
case 'b' :
|
||||
case 'i' :
|
||||
case 'd' :
|
||||
if ( preg_match("/^{$badions[1]}:[0-9.E-]+;\$/", $data) )
|
||||
return true;
|
||||
break;
|
||||
endswitch;
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_serialized_string($data) {
|
||||
if ( !is_string($data) ) // if it isn't a string, it isn't a serialized string
|
||||
// if it isn't a string, it isn't a serialized string
|
||||
if ( !is_string($data) )
|
||||
return false;
|
||||
$data = trim($data);
|
||||
if ( preg_match("/^s:[0-9]+:.*[;}]/si",$data) ) // this should fetch all serialized strings
|
||||
if ( preg_match('/^s:[0-9]+:.*;$/s',$data) ) // this should fetch all serialized strings
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@ -1202,5 +1220,4 @@ function _mce_add_direction_buttons($input) {
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user