Commit 1e371922 authored by Benni Mack's avatar Benni Mack
Browse files

[BUGFIX] Make DataHandler multibyte-safe

There are still a few places left where multibyte string functions
are not used. Since 8.x the core delivers a mbstring polyfill
and can be used in various places.

Resolves: #19774
Releases: master, 8.7
Change-Id: I16f022b109749e9f547c177c511fee3bcc5d4b60
Reviewed-on: https://review.typo3.org/52752


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 9743e3cf
......@@ -791,7 +791,7 @@ class DataHandler
}
foreach ($userTS as $k => $v) {
$k = substr($k, 0, -1);
$k = mb_substr($k, 0, -1);
if (!$k || !is_array($v) || !isset($GLOBALS['TCA'][$k])) {
continue;
}
......@@ -2757,12 +2757,12 @@ class DataHandler
}
break;
case 'is_in':
$c = strlen($value);
$c = mb_strlen($value);
if ($c) {
$newVal = '';
for ($a = 0; $a < $c; $a++) {
$char = substr($value, $a, 1);
if (strpos($is_in, $char) !== false) {
$char = mb_substr($value, $a, 1);
if (mb_strpos($is_in, $char) !== false) {
$newVal .= $char;
}
}
......@@ -3031,7 +3031,7 @@ class DataHandler
}
// Finally, check if new and old values are different (or no .vDEFbase value is found) and if so, we record the vDEF value for diff'ing.
// We do this after $dataValues has been updated since I expect that $dataValues_current holds evaluated values from database (so this must be the right value to compare with).
if (substr($vKey, -9) !== '.vDEFbase') {
if (mb_substr($vKey, -9) !== '.vDEFbase') {
if ($this->updateModeL10NdiffData && $GLOBALS['TYPO3_CONF_VARS']['BE']['flexFormXMLincludeDiffBase'] && $vKey !== 'vDEF' && ((string)$dataValues[$key][$vKey] !== (string)$dataValues_current[$key][$vKey] || !isset($dataValues_current[$key][$vKey . '.vDEFbase']) || $this->updateModeL10NdiffData === 'FORCE_FFUPD')) {
// Now, check if a vDEF value is submitted in the input data, if so we expect this has been processed prior to this operation (normally the case since those fields are higher in the form) and we can use that:
if (isset($dataValues[$key]['vDEF'])) {
......@@ -4050,7 +4050,7 @@ class DataHandler
}
$fileInfo = [];
$fileInfo['exists'] = @is_file((PATH_site . $rteFileRecord['ref_string']));
$fileInfo['original'] = substr($rteFileRecord['ref_string'], 0, -strlen($filename)) . 'RTEmagicP_' . preg_replace('/\\.[[:alnum:]]+$/', '', substr($filename, 10));
$fileInfo['original'] = mb_substr($rteFileRecord['ref_string'], 0, -mb_strlen($filename)) . 'RTEmagicP_' . preg_replace('/\\.[[:alnum:]]+$/', '', mb_substr($filename, 10));
$fileInfo['original_exists'] = @is_file((PATH_site . $fileInfo['original']));
// CODE from tx_impexp and class.rte_images.php adapted for use here:
if (!$fileInfo['exists'] || !$fileInfo['original_exists']) {
......@@ -4069,7 +4069,7 @@ class DataHandler
$origDestName = $this->fileFunc->getUniqueName($rteOrigName, PATH_site . $dirPrefix);
// Create copy file name:
$pI = pathinfo($rteFileRecord['ref_string']);
$copyDestName = dirname($origDestName) . '/RTEmagicC_' . substr(basename($origDestName), 10) . '.' . $pI['extension'];
$copyDestName = dirname($origDestName) . '/RTEmagicC_' . mb_substr(basename($origDestName), 10) . '.' . $pI['extension'];
if (!@is_file($copyDestName) && !@is_file($origDestName) && $origDestName === GeneralUtility::getFileAbsFileName($origDestName) && $copyDestName === GeneralUtility::getFileAbsFileName($copyDestName)) {
// Making copies:
GeneralUtility::upload_copy_move(PATH_site . $fileInfo['original'], $origDestName);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment