N°3448 - Framework field size check not correctly implemented for multibytes languages/strings (#528)

This commit is contained in:
Anne-Catherine
2024-01-15 16:10:23 +01:00
committed by GitHub
parent a8cd9566ac
commit cff50f8732
7 changed files with 207 additions and 70 deletions

View File

@@ -1930,17 +1930,13 @@ class SynchroLog extends DBObject
$oAttDef = MetaModel::GetAttributeDef(get_class($this), 'traces');
$iMaxSize = $oAttDef->GetMaxSize();
if (strlen($sPrevTrace) > 0)
{
if (strlen($sPrevTrace) > 0) {
$sTrace = $sPrevTrace."\n".implode("\n", $this->m_aTraces);
}
else
{
} else {
$sTrace = implode("\n", $this->m_aTraces);
}
if (strlen($sTrace) >= $iMaxSize)
{
$sTrace = substr($sTrace, 0, $iMaxSize - 255)."...\nTruncated (size: ".strlen($sTrace).')';
if (mb_strlen($sTrace) >= $iMaxSize) {
$sTrace = mb_substr($sTrace, 0, $iMaxSize - 40)."...\nTruncated (size: ".mb_strlen($sTrace).')';
}
$this->Set('traces', $sTrace);
@@ -2145,9 +2141,8 @@ class SynchroReplica extends DBObject implements iDisplay
break;
}
if (strlen($sWarningMessage) > $MAX_WARNING_LENGTH)
{
$sWarningMessage = substr($sWarningMessage, 0, $MAX_WARNING_LENGTH - 3).'...';
if (mb_strlen($sWarningMessage) > $MAX_WARNING_LENGTH) {
$sWarningMessage = mb_substr($sWarningMessage, 0, $MAX_WARNING_LENGTH - 3).'...';
}
$this->Set('status_last_warning', $sWarningMessage);
@@ -2187,17 +2182,13 @@ class SynchroReplica extends DBObject implements iDisplay
public function SetLastError($sMessage, $oException = null)
{
if ($oException)
{
if ($oException) {
$sText = $sMessage.$oException->getMessage();
}
else
{
} else {
$sText = $sMessage;
}
if (strlen($sText) > 255)
{
$sText = substr($sText, 0, 200).'...('.strlen($sText).' chars)...';
if (mb_strlen($sText) > 255) {
$sText = mb_substr($sText, 0, 200).'...('.mb_strlen($sText).' chars)...';
}
$this->Set('status_last_error', $sText);
}