Merge branch 'MDL-67017' of https://github.com/stronk7/moodle
This commit is contained in:
@@ -679,7 +679,7 @@ class t3lib_cs {
|
||||
$chr = substr($str, $a, 1);
|
||||
$ord = ord($chr);
|
||||
if (isset($this->twoByteSets[$charset])) { // If the charset has two bytes per char
|
||||
$ord2 = ord($str{$a + 1});
|
||||
$ord2 = ord($str[$a + 1]);
|
||||
$ord = $ord << 8 | $ord2; // assume big endian
|
||||
|
||||
if (isset($this->parsedCharsets[$charset]['local'][$ord])) { // If the local char-number was found in parsed conv. table then we use that, otherwise 127 (no char?)
|
||||
@@ -1164,7 +1164,7 @@ class t3lib_cs {
|
||||
$utf8CaseFolding['toTitle'][$utf8_char] = $this->UnumberToChar(hexdec($title));
|
||||
}
|
||||
|
||||
switch ($cat{0}) {
|
||||
switch ($cat[0]) {
|
||||
case 'M': // mark (accent, umlaut, ...)
|
||||
$mark["U+$char"] = 1;
|
||||
break;
|
||||
@@ -1224,10 +1224,10 @@ class t3lib_cs {
|
||||
if ($fh) {
|
||||
while (!feof($fh)) {
|
||||
$line = fgets($fh, 4096);
|
||||
if ($line{0} != '#' && trim($line) != '') {
|
||||
if ($line[0] != '#' && trim($line) != '') {
|
||||
|
||||
list($char, $lower, $title, $upper, $cond) = t3lib_div::trimExplode(';', $line);
|
||||
if ($cond == '' || $cond{0} == '#') {
|
||||
if ($cond == '' || $cond[0] == '#') {
|
||||
$utf8_char = $this->UnumberToChar(hexdec($char));
|
||||
if ($char != $lower) {
|
||||
$arr = explode(' ', $lower);
|
||||
@@ -1264,7 +1264,7 @@ class t3lib_cs {
|
||||
if ($fh) {
|
||||
while (!feof($fh)) {
|
||||
$line = fgets($fh, 4096);
|
||||
if ($line{0} != '#' && trim($line) != '') {
|
||||
if ($line[0] != '#' && trim($line) != '') {
|
||||
list($char, $translit) = t3lib_div::trimExplode(';', $line);
|
||||
if (!$translit) {
|
||||
$omit["U+$char"] = 1;
|
||||
@@ -1609,12 +1609,12 @@ class t3lib_cs {
|
||||
return $string;
|
||||
} else {
|
||||
if ($len > 0) {
|
||||
if (strlen($string{$i})) {
|
||||
if (strlen($string[$i])) {
|
||||
return substr($string, 0, $i) . $crop;
|
||||
|
||||
}
|
||||
} else {
|
||||
if (strlen($string{$i - 1})) {
|
||||
if (strlen($string[$i - 1])) {
|
||||
return $crop . substr($string, $i);
|
||||
}
|
||||
}
|
||||
@@ -1835,8 +1835,8 @@ class t3lib_cs {
|
||||
}
|
||||
|
||||
$out = '';
|
||||
for ($i = 0; strlen($str{$i}); $i++) {
|
||||
$c = $str{$i};
|
||||
for ($i = 0; strlen($str[$i]); $i++) {
|
||||
$c = $str[$i];
|
||||
if (isset($map[$c])) {
|
||||
$out .= $map[$c];
|
||||
} else {
|
||||
@@ -1908,8 +1908,8 @@ class t3lib_cs {
|
||||
*/
|
||||
function utf8_strlen($str) {
|
||||
$n = 0;
|
||||
for ($i = 0; strlen($str{$i}); $i++) {
|
||||
$c = ord($str{$i});
|
||||
for ($i = 0; strlen($str[$i]); $i++) {
|
||||
$c = ord($str[$i]);
|
||||
if (!($c & 0x80)) // single-byte (0xxxxxx)
|
||||
{
|
||||
$n++;
|
||||
@@ -1933,15 +1933,15 @@ class t3lib_cs {
|
||||
*/
|
||||
function utf8_strtrunc($str, $len) {
|
||||
$i = $len - 1;
|
||||
if (ord($str{$i}) & 0x80) { // part of a multibyte sequence
|
||||
for (; $i > 0 && !(ord($str{$i}) & 0x40); $i--) {
|
||||
if (ord($str[$i]) & 0x80) { // part of a multibyte sequence
|
||||
for (; $i > 0 && !(ord($str[$i]) & 0x40); $i--) {
|
||||
// find the first byte
|
||||
;
|
||||
}
|
||||
if ($i <= 0) {
|
||||
return '';
|
||||
} // sanity check
|
||||
for ($bc = 0, $mbs = ord($str{$i}); $mbs & 0x80; $mbs = $mbs << 1) {
|
||||
for ($bc = 0, $mbs = ord($str[$i]); $mbs & 0x80; $mbs = $mbs << 1) {
|
||||
// calculate number of bytes
|
||||
$bc++;
|
||||
}
|
||||
@@ -2028,8 +2028,8 @@ class t3lib_cs {
|
||||
$d = -1;
|
||||
}
|
||||
|
||||
for (; strlen($str{$i}) && $n < $p; $i += $d) {
|
||||
$c = (int) ord($str{$i});
|
||||
for (; strlen($str[$i]) && $n < $p; $i += $d) {
|
||||
$c = (int) ord($str[$i]);
|
||||
if (!($c & 0x80)) // single-byte (0xxxxxx)
|
||||
{
|
||||
$n++;
|
||||
@@ -2039,13 +2039,13 @@ class t3lib_cs {
|
||||
$n++;
|
||||
}
|
||||
}
|
||||
if (!strlen($str{$i})) {
|
||||
if (!strlen($str[$i])) {
|
||||
return FALSE;
|
||||
} // offset beyond string length
|
||||
|
||||
if ($pos >= 0) {
|
||||
// skip trailing multi-byte data bytes
|
||||
while ((ord($str{$i}) & 0x80) && !(ord($str{$i}) & 0x40)) {
|
||||
while ((ord($str[$i]) & 0x80) && !(ord($str[$i]) & 0x40)) {
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
@@ -2068,7 +2068,7 @@ class t3lib_cs {
|
||||
function utf8_byte2char_pos($str, $pos) {
|
||||
$n = 0; // number of characters
|
||||
for ($i = $pos; $i > 0; $i--) {
|
||||
$c = (int) ord($str{$i});
|
||||
$c = (int) ord($str[$i]);
|
||||
if (!($c & 0x80)) // single-byte (0xxxxxx)
|
||||
{
|
||||
$n++;
|
||||
@@ -2078,7 +2078,7 @@ class t3lib_cs {
|
||||
$n++;
|
||||
}
|
||||
}
|
||||
if (!strlen($str{$i})) {
|
||||
if (!strlen($str[$i])) {
|
||||
return FALSE;
|
||||
} // offset beyond string length
|
||||
|
||||
@@ -2113,11 +2113,11 @@ class t3lib_cs {
|
||||
return $str;
|
||||
}
|
||||
|
||||
for ($i = 0; strlen($str{$i}); $i++) {
|
||||
$c = ord($str{$i});
|
||||
for ($i = 0; strlen($str[$i]); $i++) {
|
||||
$c = ord($str[$i]);
|
||||
if (!($c & 0x80)) // single-byte (0xxxxxx)
|
||||
{
|
||||
$mbc = $str{$i};
|
||||
$mbc = $str[$i];
|
||||
}
|
||||
elseif (($c & 0xC0) == 0xC0) { // multi-byte starting byte (11xxxxxx)
|
||||
for ($bc = 0; $c & 0x80; $c = $c << 1) {
|
||||
@@ -2162,8 +2162,8 @@ class t3lib_cs {
|
||||
*/
|
||||
function euc_strtrunc($str, $len, $charset) {
|
||||
$sjis = ($charset == 'shift_jis');
|
||||
for ($i = 0; strlen($str{$i}) && $i < $len; $i++) {
|
||||
$c = ord($str{$i});
|
||||
for ($i = 0; strlen($str[$i]) && $i < $len; $i++) {
|
||||
$c = ord($str[$i]);
|
||||
if ($sjis) {
|
||||
if (($c >= 0x80 && $c < 0xA0) || ($c >= 0xE0)) {
|
||||
$i++;
|
||||
@@ -2175,7 +2175,7 @@ class t3lib_cs {
|
||||
} // advance a double-byte char
|
||||
}
|
||||
}
|
||||
if (!strlen($str{$i})) {
|
||||
if (!strlen($str[$i])) {
|
||||
return $str;
|
||||
} // string shorter than supplied length
|
||||
|
||||
@@ -2232,8 +2232,8 @@ class t3lib_cs {
|
||||
function euc_strlen($str, $charset) {
|
||||
$sjis = ($charset == 'shift_jis');
|
||||
$n = 0;
|
||||
for ($i = 0; strlen($str{$i}); $i++) {
|
||||
$c = ord($str{$i});
|
||||
for ($i = 0; strlen($str[$i]); $i++) {
|
||||
$c = ord($str[$i]);
|
||||
if ($sjis) {
|
||||
if (($c >= 0x80 && $c < 0xA0) || ($c >= 0xE0)) {
|
||||
$i++;
|
||||
@@ -2273,8 +2273,8 @@ class t3lib_cs {
|
||||
$d = -1;
|
||||
}
|
||||
|
||||
for (; strlen($str{$i}) && $n < $p; $i += $d) {
|
||||
$c = ord($str{$i});
|
||||
for (; strlen($str[$i]) && $n < $p; $i += $d) {
|
||||
$c = ord($str[$i]);
|
||||
if ($sjis) {
|
||||
if (($c >= 0x80 && $c < 0xA0) || ($c >= 0xE0)) {
|
||||
$i += $d;
|
||||
@@ -2288,7 +2288,7 @@ class t3lib_cs {
|
||||
|
||||
$n++;
|
||||
}
|
||||
if (!strlen($str{$i})) {
|
||||
if (!strlen($str[$i])) {
|
||||
return FALSE;
|
||||
} // offset beyond string length
|
||||
|
||||
@@ -2331,8 +2331,8 @@ class t3lib_cs {
|
||||
|
||||
$sjis = ($charset == 'shift_jis');
|
||||
$out = '';
|
||||
for ($i = 0; strlen($str{$i}); $i++) {
|
||||
$mbc = $str{$i};
|
||||
for ($i = 0; strlen($str[$i]); $i++) {
|
||||
$mbc = $str[$i];
|
||||
$c = ord($mbc);
|
||||
|
||||
if ($sjis) {
|
||||
|
||||
@@ -1363,7 +1363,7 @@ final class t3lib_div {
|
||||
$bytesToGenerate = max(4096, $bytesToReturn);
|
||||
|
||||
// if we have not enough random bytes cached, we generate new ones
|
||||
if (!isset($bytes{$bytesToReturn - 1})) {
|
||||
if (!isset($bytes[$bytesToReturn - 1])) {
|
||||
if (TYPO3_OS === 'WIN') {
|
||||
// Openssl seems to be deadly slow on Windows, so try to use mcrypt
|
||||
// Windows PHP versions have a bug when using urandom source (see #24410)
|
||||
@@ -1372,18 +1372,18 @@ final class t3lib_div {
|
||||
// Try to use native PHP functions first, precedence has openssl
|
||||
$bytes .= self::generateRandomBytesOpenSsl($bytesToGenerate);
|
||||
|
||||
if (!isset($bytes{$bytesToReturn - 1})) {
|
||||
if (!isset($bytes[$bytesToReturn - 1])) {
|
||||
$bytes .= self::generateRandomBytesMcrypt($bytesToGenerate, MCRYPT_DEV_URANDOM);
|
||||
}
|
||||
|
||||
// If openssl and mcrypt failed, try /dev/urandom
|
||||
if (!isset($bytes{$bytesToReturn - 1})) {
|
||||
if (!isset($bytes[$bytesToReturn - 1])) {
|
||||
$bytes .= self::generateRandomBytesUrandom($bytesToGenerate);
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back if other random byte generation failed until now
|
||||
if (!isset($bytes{$bytesToReturn - 1})) {
|
||||
if (!isset($bytes[$bytesToReturn - 1])) {
|
||||
$bytes .= self::generateRandomBytesFallback($bytesToReturn);
|
||||
}
|
||||
}
|
||||
@@ -1453,7 +1453,7 @@ final class t3lib_div {
|
||||
$bytes = '';
|
||||
// We initialize with somewhat random.
|
||||
$randomState = $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] . base_convert(memory_get_usage() % pow(10, 6), 10, 2) . microtime() . uniqid('') . getmypid();
|
||||
while (!isset($bytes{$bytesToReturn - 1})) {
|
||||
while (!isset($bytes[$bytesToReturn - 1])) {
|
||||
$randomState = sha1(microtime() . mt_rand() . $randomState);
|
||||
$bytes .= sha1(mt_rand() . $randomState, TRUE);
|
||||
}
|
||||
@@ -5318,7 +5318,7 @@ final class t3lib_div {
|
||||
$matches = preg_split('/(.?###.+###.?|\(|\))/', $line, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($matches as $part) {
|
||||
$oldPart = $part;
|
||||
$partWasQuoted = ($part{0} == '"');
|
||||
$partWasQuoted = ($part[0] == '"');
|
||||
$part = trim($part, '"');
|
||||
switch ((string) $enc) {
|
||||
case 'base64':
|
||||
|
||||
@@ -10,6 +10,11 @@ Procedure:
|
||||
|
||||
Local changes (to verify/apply with new imports):
|
||||
|
||||
- MDL-67017: PHP 7.4 compatibility. Curly brackets.
|
||||
Remove all the deprecated curly bracket uses {} to access to strings/arrays
|
||||
by key. We haven't looked how this is fixed upstream because plans include
|
||||
to remove this library from core (see MDL-65809)
|
||||
|
||||
- MDL-63967: PHP 7.3 compatibility.
|
||||
lib/typo3/class.t3lib_div.php: FILTER_FLAG_SCHEME_REQUIRED is deprecated and
|
||||
implied with FILTER_VALIDATE_URL. This is fixed upstream since Typo 6, with
|
||||
|
||||
Reference in New Issue
Block a user