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:
Dominik Schilling (ocean90)
2016-03-08 17:14:52 +00:00
parent 5064747619
commit dfc6f47841
10 changed files with 134 additions and 47 deletions

View File

@@ -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);
}
}