Bugfix: Trying to access array offset on value of type null

Now that the ResponseParser is fixed and handles NIL the BodyStructure class bug was detected
This commit is contained in:
djmaze 2021-11-04 16:27:08 +01:00
parent 40b8bf3d7e
commit a6ebee8e13

View file

@ -680,7 +680,6 @@ class BodyStructure
return null; return null;
} }
} }
}
$aDispParamList = $aDispList[1]; $aDispParamList = $aDispList[1];
if (\is_array($aDispParamList)) if (\is_array($aDispParamList))
@ -689,11 +688,12 @@ class BodyStructure
$sFileName = self::decodeAttrParameter($aDispositionParams, 'filename', $sCharset ?: ''); $sFileName = self::decodeAttrParameter($aDispositionParams, 'filename', $sCharset ?: '');
} }
} }
}
++$iExtraItemPos; ++$iExtraItemPos;
$sLanguage = null; $sLanguage = null;
if ($iExtraItemPos < count($aBodyStructure)) if ($iExtraItemPos < \count($aBodyStructure))
{ {
if (null !== $aBodyStructure[$iExtraItemPos] && 'NIL' !== $aBodyStructure[$iExtraItemPos]) if (null !== $aBodyStructure[$iExtraItemPos] && 'NIL' !== $aBodyStructure[$iExtraItemPos])
{ {
@ -778,9 +778,10 @@ class BodyStructure
private static function getKeyValueListFromArrayList(array $aList) : array private static function getKeyValueListFromArrayList(array $aList) : array
{ {
$aDict = array(); $aDict = array();
if (0 === \count($aList) % 2) $iLen = \count($aList);
if (0 === ($iLen % 2))
{ {
for ($iIndex = 0, $iLen = \count($aList); $iIndex < $iLen; $iIndex += 2) for ($iIndex = 0; $iIndex < $iLen; $iIndex += 2)
{ {
if (\is_string($aList[$iIndex]) && isset($aList[$iIndex + 1]) && \is_string($aList[$iIndex + 1])) if (\is_string($aList[$iIndex]) && isset($aList[$iIndex + 1]) && \is_string($aList[$iIndex + 1]))
{ {