mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Update Random_Compat from 1.1.6 to 1.2.1.
Changes: https://github.com/paragonie/random_compat/compare/1.1.6...v1.2.1 See #35665. git-svn-id: https://develop.svn.wordpress.org/trunk@36886 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -50,8 +50,10 @@ if (!function_exists('RandomCompat_strlen')) {
|
||||
'RandomCompat_strlen() expects a string'
|
||||
);
|
||||
}
|
||||
|
||||
return mb_strlen($binary_string, '8bit');
|
||||
}
|
||||
|
||||
} else {
|
||||
/**
|
||||
* strlen() implementation that isn't brittle to mbstring.func_overload
|
||||
@@ -77,8 +79,10 @@ if (!function_exists('RandomCompat_strlen')) {
|
||||
}
|
||||
|
||||
if (!function_exists('RandomCompat_substr')) {
|
||||
|
||||
if (
|
||||
defined('MB_OVERLOAD_STRING') &&
|
||||
defined('MB_OVERLOAD_STRING')
|
||||
&&
|
||||
ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING
|
||||
) {
|
||||
/**
|
||||
@@ -102,11 +106,13 @@ if (!function_exists('RandomCompat_substr')) {
|
||||
'RandomCompat_substr(): First argument should be a string'
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_int($start)) {
|
||||
throw new TypeError(
|
||||
'RandomCompat_substr(): Second argument should be an integer'
|
||||
);
|
||||
}
|
||||
|
||||
if ($length === null) {
|
||||
/**
|
||||
* mb_substr($str, 0, NULL, '8bit') returns an empty string on
|
||||
@@ -118,9 +124,12 @@ if (!function_exists('RandomCompat_substr')) {
|
||||
'RandomCompat_substr(): Third argument should be an integer, or omitted'
|
||||
);
|
||||
}
|
||||
|
||||
return mb_substr($binary_string, $start, $length, '8bit');
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/**
|
||||
* substr() implementation that isn't brittle to mbstring.func_overload
|
||||
*
|
||||
@@ -141,19 +150,23 @@ if (!function_exists('RandomCompat_substr')) {
|
||||
'RandomCompat_substr(): First argument should be a string'
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_int($start)) {
|
||||
throw new TypeError(
|
||||
'RandomCompat_substr(): Second argument should be an integer'
|
||||
);
|
||||
}
|
||||
|
||||
if ($length !== null) {
|
||||
if (!is_int($length)) {
|
||||
throw new TypeError(
|
||||
'RandomCompat_substr(): Third argument should be an integer, or omitted'
|
||||
);
|
||||
}
|
||||
|
||||
return substr($binary_string, $start, $length);
|
||||
}
|
||||
|
||||
return substr($binary_string, $start);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user