summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/dav/lib/CalDAV/BirthdayService.php7
-rw-r--r--apps/dav/lib/Connector/Sabre/TagsPlugin.php3
-rw-r--r--apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php2
-rw-r--r--apps/files_external/lib/Lib/Storage/OwnCloud.php5
-rw-r--r--apps/files_external/lib/Lib/Storage/SFTP.php9
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php10
-rw-r--r--apps/files_trashbin/lib/Trashbin.php2
-rw-r--r--apps/theming/appinfo/info.xml6
-rw-r--r--apps/theming/lib/Migration/ThemingImages.php77
-rw-r--r--apps/theming/tests/Migration/ThemingImages.php139
-rw-r--r--lib/private/App/AppStore/Version/VersionParser.php5
-rw-r--r--lib/private/Archive/TAR.php9
-rw-r--r--lib/private/Avatar.php2
-rw-r--r--lib/private/Files/Filesystem.php4
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreStorage.php3
-rw-r--r--lib/private/Files/Storage/DAV.php10
-rw-r--r--lib/private/Files/View.php6
-rw-r--r--lib/private/Installer.php2
-rw-r--r--lib/private/Settings/Personal/PersonalInfo.php2
-rw-r--r--lib/private/legacy/image.php6
20 files changed, 31 insertions, 278 deletions
diff --git a/apps/dav/lib/CalDAV/BirthdayService.php b/apps/dav/lib/CalDAV/BirthdayService.php
index 62d218f0a2a..0f6e819bcc5 100644
--- a/apps/dav/lib/CalDAV/BirthdayService.php
+++ b/apps/dav/lib/CalDAV/BirthdayService.php
@@ -148,10 +148,11 @@ class BirthdayService {
/**
* @param string $cardData
* @param string $dateField
+ * @param string $postfix
* @param string $summarySymbol
* @return null|VCalendar
*/
- public function buildDateFromContact($cardData, $dateField, $summarySymbol) {
+ public function buildDateFromContact($cardData, $dateField, $postfix, $summarySymbol) {
if (empty($cardData)) {
return null;
}
@@ -221,7 +222,7 @@ class BirthdayService {
$date
);
$vEvent->DTEND['VALUE'] = 'DATE';
- $vEvent->{'UID'} = $doc->UID;
+ $vEvent->{'UID'} = $doc->UID . $postfix;
$vEvent->{'RRULE'} = 'FREQ=YEARLY';
$vEvent->{'SUMMARY'} = $summary;
$vEvent->{'TRANSP'} = 'TRANSPARENT';
@@ -297,7 +298,7 @@ class BirthdayService {
*/
private function updateCalendar($cardUri, $cardData, $book, $calendarId, $type) {
$objectUri = $book['uri'] . '-' . $cardUri . $type['postfix'] . '.ics';
- $calendarData = $this->buildDateFromContact($cardData, $type['field'], $type['symbol']);
+ $calendarData = $this->buildDateFromContact($cardData, $type['field'], $type['postfix'], $type['symbol']);
$existing = $this->calDavBackEnd->getCalendarObject($calendarId, $objectUri);
if (is_null($calendarData)) {
if (!is_null($existing)) {
diff --git a/apps/dav/lib/Connector/Sabre/TagsPlugin.php b/apps/dav/lib/Connector/Sabre/TagsPlugin.php
index 07e0f849a57..229826c0a7a 100644
--- a/apps/dav/lib/Connector/Sabre/TagsPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/TagsPlugin.php
@@ -240,10 +240,9 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin
}
}
- $tags = null;
$isFav = null;
- $propFind->handle(self::TAGS_PROPERTYNAME, function() use ($tags, &$isFav, $node) {
+ $propFind->handle(self::TAGS_PROPERTYNAME, function() use (&$isFav, $node) {
list($tags, $isFav) = $this->getTagsAndFav($node->getId());
return new TagList($tags);
});
diff --git a/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php b/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php
index 867168033a4..739b81ddf01 100644
--- a/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php
+++ b/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php
@@ -64,7 +64,7 @@ class BirthdayServiceTest extends TestCase {
* @param string | null $data
*/
public function testBuildBirthdayFromContact($expectedSummary, $data) {
- $cal = $this->service->buildDateFromContact($data, 'BDAY', '*');
+ $cal = $this->service->buildDateFromContact($data, 'BDAY', '', '*');
if ($expectedSummary === null) {
$this->assertNull($cal);
} else {
diff --git a/apps/files_external/lib/Lib/Storage/OwnCloud.php b/apps/files_external/lib/Lib/Storage/OwnCloud.php
index d846fa811a0..d56e6b66145 100644
--- a/apps/files_external/lib/Lib/Storage/OwnCloud.php
+++ b/apps/files_external/lib/Lib/Storage/OwnCloud.php
@@ -61,10 +61,7 @@ class OwnCloud extends \OC\Files\Storage\DAV{
}
if (isset($params['root'])){
- $root = $params['root'];
- if (substr($root, 0, 1) !== '/'){
- $root = '/' . $root;
- }
+ $root = '/' . ltrim($params['root'], '/');
}
else{
$root = '/';
diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php
index 22162fa61cf..6bd77dd2496 100644
--- a/apps/files_external/lib/Lib/Storage/SFTP.php
+++ b/apps/files_external/lib/Lib/Storage/SFTP.php
@@ -103,13 +103,8 @@ class SFTP extends \OC\Files\Storage\Common {
$this->root
= isset($params['root']) ? $this->cleanPath($params['root']) : '/';
- if ($this->root[0] !== '/') {
- $this->root = '/' . $this->root;
- }
-
- if (substr($this->root, -1, 1) !== '/') {
- $this->root .= '/';
- }
+ $this->root = '/' . ltrim($this->root, '/');
+ $this->root = rtrim($this->root, '/') . '/';
}
/**
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index d8bbe8c4718..58a6f65990f 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -84,13 +84,9 @@ class SMB extends Common implements INotifyStorage {
}
$this->share = $this->server->getShare(trim($params['share'], '/'));
- $this->root = isset($params['root']) ? $params['root'] : '/';
- if (!$this->root || $this->root[0] !== '/') {
- $this->root = '/' . $this->root;
- }
- if (substr($this->root, -1, 1) !== '/') {
- $this->root .= '/';
- }
+ $this->root = $params['root'] ?? '/';
+ $this->root = '/' . ltrim($this->root, '/');
+ $this->root = rtrim($this->root, '/') . '/';
} else {
throw new \Exception('Invalid configuration');
}
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php
index d61881ce3b1..ca4b406c648 100644
--- a/apps/files_trashbin/lib/Trashbin.php
+++ b/apps/files_trashbin/lib/Trashbin.php
@@ -635,8 +635,6 @@ class Trashbin {
if ($timestamp) {
$filename = $filename . '.d' . $timestamp;
- } else {
- $filename = $filename;
}
$target = Filesystem::normalizePath('files_trashbin/files/' . $filename);
diff --git a/apps/theming/appinfo/info.xml b/apps/theming/appinfo/info.xml
index 11a8d2f73f7..d2eacea77b3 100644
--- a/apps/theming/appinfo/info.xml
+++ b/apps/theming/appinfo/info.xml
@@ -23,10 +23,4 @@
<admin>OCA\Theming\Settings\Admin</admin>
<admin-section>OCA\Theming\Settings\Section</admin-section>
</settings>
-
- <repair-steps>
- <post-migration>
- <step>OCA\Theming\Migration\ThemingImages</step>
- </post-migration>
- </repair-steps>
</info>
diff --git a/apps/theming/lib/Migration/ThemingImages.php b/apps/theming/lib/Migration/ThemingImages.php
deleted file mode 100644
index 4f929746cb1..00000000000
--- a/apps/theming/lib/Migration/ThemingImages.php
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2017 Julius Härtl <jus@bitgrid.net>
- *
- * @author Julius Haertl <jus@bitgrid.net>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-namespace OCA\Theming\Migration;
-
-use OCA\Theming\ThemingDefaults;
-use OCP\Files\IAppData;
-use OCP\Files\IRootFolder;
-use OCP\Migration\IRepairStep;
-use OCP\Migration\IOutput;
-use OC\Files\Node\File;
-use OCP\Files\NotFoundException;
-
-class ThemingImages implements IRepairStep {
-
- private $appData;
- private $rootFolder;
-
- public function __construct(IAppData $appData, IRootFolder $rootFolder) {
- $this->appData = $appData;
- $this->rootFolder = $rootFolder;
- }
-
- /*
- * @inheritdoc
- */
- public function getName() {
- return 'Move theming files to AppData storage';
- }
-
- /**
- * @inheritdoc
- */
- public function run(IOutput $output) {
- $folder = $this->appData->newFolder("images");
- /** @var File $file */
- $file = null;
- try {
- $file = $this->rootFolder->get('themedinstancelogo');
- $logo = $folder->newFile('logo');
- $logo->putContent($file->getContent());
- $file->delete();
- } catch (NotFoundException $e) {
- $output->info('No theming logo image to migrate');
- }
-
- try {
- $file = $this->rootFolder->get('themedbackgroundlogo');
- $background = $folder->newFile('background');
- $background->putContent($file->getContent());
- $file->delete();
- } catch (NotFoundException $e) {
- $output->info('No theming background image to migrate');
- }
- }
-}
diff --git a/apps/theming/tests/Migration/ThemingImages.php b/apps/theming/tests/Migration/ThemingImages.php
deleted file mode 100644
index a8d066c26f7..00000000000
--- a/apps/theming/tests/Migration/ThemingImages.php
+++ /dev/null
@@ -1,139 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2017 Julius Härtl <jus@bitgrid.net>
- *
- * @author Julius Haertl <jus@bitgrid.net>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace OCA\Theming\Tests\Migration;
-
-use OCP\Files\File;
-use OCP\Files\NotFoundException;
-use OCP\Files\SimpleFS\ISimpleFile;
-use OCP\Files\SimpleFS\ISimpleFolder;
-use OCP\Migration\IOutput;
-use Test\TestCase;
-use OCA\Theming\Migration\ThemingImages;
-use OCP\Files\IAppData;
-use OCP\Files\IRootFolder;
-
-class ThemingImagesTest extends TestCase {
- /** @var ThemingImages */
- private $repairStep;
- /** @var IAppData */
- private $appData;
- /** @var IRootFolder */
- private $rootFolder;
- /** @var ISimpleFolder */
- private $imageFolder;
- /** @var IOutput */
- private $output;
-
- public function setUp() {
- parent::setUp();
- $this->appData = $this->createMock(IAppData::class);
- $this->rootFolder = $this->createMock(IRootFolder::class);
- $this->repairStep = new ThemingImages($this->appData, $this->rootFolder);
- $this->imageFolder = $this->createMock(ISimpleFolder::class);
- $this->output = $this->createMock(IOutput::class);
- }
-
- public function testGetName() {
- $this->assertEquals(
- 'Move theming files to AppData storage',
- $this->repairStep->getName()
- );
- }
-
- public function testRunNoImages() {
- $this->appData->expects($this->once())
- ->method('newFolder')
- ->willReturn($this->imageFolder);
- $this->rootFolder->expects($this->any())
- ->method('get')
- ->willThrowException(new NotFoundException());
- $this->imageFolder->expects($this->never())
- ->method('newFile');
- $this->output->expects($this->exactly(2))
- ->method('info');
- $this->repairStep->run($this->output);
- }
-
- public function testRunLogo() {
- $oldFile = $this->createMock(File::class);
- $newFile = $this->createMock(ISimpleFile::class);
-
- $this->appData->expects($this->once())
- ->method('newFolder')
- ->willReturn($this->imageFolder);
- $this->rootFolder->expects($this->at(1))
- ->method('get')
- ->with('themedbackgroundlogo')
- ->willThrowException(new NotFoundException());
- $this->rootFolder->expects($this->at(0))
- ->method('get')
- ->with('themedinstancelogo')
- ->willReturn($oldFile);
- $this->imageFolder->expects($this->once())
- ->method('newFile')
- ->with('logo')
- ->willReturn($newFile);
- $oldFile->expects($this->once())
- ->method('getContent')
- ->willReturn('data');
- $newFile->expects($this->once())
- ->method('putContent')
- ->with('data');
- $oldFile->expects($this->once())
- ->method('delete');
-
- $this->repairStep->run($this->output);
- }
-
- public function testRunBackground() {
- $oldFile = $this->createMock(File::class);
- $newFile = $this->createMock(ISimpleFile::class);
-
- $this->appData->expects($this->once())
- ->method('newFolder')
- ->willReturn($this->imageFolder);
- $this->rootFolder->expects($this->at(1))
- ->method('get')
- ->with('themedbackgroundlogo')
- ->willReturn($oldFile);
- $this->rootFolder->expects($this->at(0))
- ->method('get')
- ->with('themedinstancelogo')
- ->willThrowException(new NotFoundException());
- $this->imageFolder->expects($this->once())
- ->method('newFile')
- ->with('background')
- ->willReturn($newFile);
- $oldFile->expects($this->once())
- ->method('getContent')
- ->willReturn('data');
- $newFile->expects($this->once())
- ->method('putContent')
- ->with('data');
- $oldFile->expects($this->once())
- ->method('delete');
-
- $this->repairStep->run($this->output);
- }
-}
diff --git a/lib/private/App/AppStore/Version/VersionParser.php b/lib/private/App/AppStore/Version/VersionParser.php
index 3924b8aea16..cdbb62ffbc5 100644
--- a/lib/private/App/AppStore/Version/VersionParser.php
+++ b/lib/private/App/AppStore/Version/VersionParser.php
@@ -63,11 +63,10 @@ class VersionParser {
if(!$this->isValidVersionString($firstVersionNumber)) {
break;
}
- if(substr($firstVersion, 0, 1) === '>') {
+ if(strpos($firstVersion, '>') === 0) {
return new Version($firstVersionNumber, '');
- } else {
- return new Version('', $firstVersionNumber);
}
+ return new Version('', $firstVersionNumber);
case 2:
if(!$this->isValidVersionString($firstVersionNumber) || !$this->isValidVersionString($secondVersionNumber)) {
break;
diff --git a/lib/private/Archive/TAR.php b/lib/private/Archive/TAR.php
index 2c34125afe6..f37da6fc52d 100644
--- a/lib/private/Archive/TAR.php
+++ b/lib/private/Archive/TAR.php
@@ -91,9 +91,7 @@ class TAR extends Archive {
*/
public function addFolder($path) {
$tmpBase = \OC::$server->getTempManager()->getTemporaryFolder();
- if (substr($path, -1, 1) != '/') {
- $path .= '/';
- }
+ $path = rtrim($path, '/') . '/';
if ($this->fileExists($path)) {
return false;
}
@@ -297,10 +295,7 @@ class TAR extends Archive {
if ((array_search($path, $files) !== false) or (array_search($path . '/', $files) !== false)) {
return true;
} else {
- $folderPath = $path;
- if (substr($folderPath, -1, 1) != '/') {
- $folderPath .= '/';
- }
+ $folderPath = rtrim($path, '/') . '/';
$pathLength = strlen($folderPath);
foreach ($files as $file) {
if (strlen($file) > $pathLength and substr($file, 0, $pathLength) == $folderPath) {
diff --git a/lib/private/Avatar.php b/lib/private/Avatar.php
index b3df607a32b..4cacc801689 100644
--- a/lib/private/Avatar.php
+++ b/lib/private/Avatar.php
@@ -263,7 +263,7 @@ class Avatar implements IAvatar {
* @return string
*/
private function generateAvatar($userDisplayName, $size) {
- $text = strtoupper(substr($userDisplayName, 0, 1));
+ $text = strtoupper($userDisplayName[0]);
$backgroundColor = $this->avatarBackgroundColor($userDisplayName);
$im = imagecreatetruecolor($size, $size);
diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php
index caf23afba11..95703eab925 100644
--- a/lib/private/Files/Filesystem.php
+++ b/lib/private/Files/Filesystem.php
@@ -839,8 +839,8 @@ class Filesystem {
$path = preg_replace('#/{2,}#', '/', $path);
//remove trailing slash
- if ($stripTrailingSlash and strlen($path) > 1 and substr($path, -1, 1) === '/') {
- $path = substr($path, 0, -1);
+ if ($stripTrailingSlash and strlen($path) > 1) {
+ $path = rtrim($path, '/');
}
// remove trailing '/.'
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
index acb8d670780..094a2915730 100644
--- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php
+++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
@@ -194,9 +194,8 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
'message' => 'Could not delete object ' . $this->getURN($stat['fileid']) . ' for ' . $path,
]);
return false;
- } else {
- //removing from cache is ok as it does not exist in the objectstore anyway
}
+ //removing from cache is ok as it does not exist in the objectstore anyway
}
$this->getCache()->remove($path);
return true;
diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php
index 43347aa0b8f..f9c6175308c 100644
--- a/lib/private/Files/Storage/DAV.php
+++ b/lib/private/Files/Storage/DAV.php
@@ -118,13 +118,9 @@ class DAV extends Common {
$this->certPath = $certPath;
}
}
- $this->root = isset($params['root']) ? $params['root'] : '/';
- if (!$this->root || $this->root[0] != '/') {
- $this->root = '/' . $this->root;
- }
- if (substr($this->root, -1, 1) != '/') {
- $this->root .= '/';
- }
+ $this->root = $params['root'] ?? '/';
+ $this->root = '/' . ltrim($this->root, '/');
+ $this->root = rtrim($this->root, '/') . '/';
} else {
throw new \Exception('Invalid webdav storage configuration');
}
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index a6971cb0205..3ab3ed89e6b 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -696,7 +696,7 @@ class View {
// do not allow deleting the root
return false;
}
- $postFix = (substr($path, -1, 1) === '/') ? '/' : '';
+ $postFix = (substr($path, -1) === '/') ? '/' : '';
$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
$mount = Filesystem::getMountManager()->find($absolutePath . $postFix);
if ($mount and $mount->getInternalPath($absolutePath) === '') {
@@ -1065,7 +1065,7 @@ class View {
* @return bool|null|string
*/
public function hash($type, $path, $raw = false) {
- $postFix = (substr($path, -1, 1) === '/') ? '/' : '';
+ $postFix = (substr($path, -1) === '/') ? '/' : '';
$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
if (Filesystem::isValidPath($path)) {
$path = $this->getRelativePath($absolutePath);
@@ -1116,7 +1116,7 @@ class View {
* \OC\Files\Storage\Storage for delegation to a storage backend for execution
*/
private function basicOperation($operation, $path, $hooks = [], $extraParam = null) {
- $postFix = (substr($path, -1, 1) === '/') ? '/' : '';
+ $postFix = (substr($path, -1) === '/') ? '/' : '';
$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
if (Filesystem::isValidPath($path)
and !Filesystem::isFileBlacklisted($path)
diff --git a/lib/private/Installer.php b/lib/private/Installer.php
index ed654c2b241..ea8ee5f01e5 100644
--- a/lib/private/Installer.php
+++ b/lib/private/Installer.php
@@ -519,7 +519,7 @@ class Installer {
foreach(\OC::$APPSROOTS as $app_dir) {
if($dir = opendir( $app_dir['path'] )) {
while( false !== ( $filename = readdir( $dir ))) {
- if( substr( $filename, 0, 1 ) != '.' and is_dir($app_dir['path']."/$filename") ) {
+ if( $filename[0] !== '.' and is_dir($app_dir['path']."/$filename") ) {
if( file_exists( $app_dir['path']."/$filename/appinfo/info.xml" )) {
if(!Installer::isInstalled($filename)) {
$info=OC_App::getAppInfo($filename);
diff --git a/lib/private/Settings/Personal/PersonalInfo.php b/lib/private/Settings/Personal/PersonalInfo.php
index dbc05cbda2f..ad277b43194 100644
--- a/lib/private/Settings/Personal/PersonalInfo.php
+++ b/lib/private/Settings/Personal/PersonalInfo.php
@@ -208,7 +208,7 @@ class PersonalInfo implements ISettings {
$l = \OC::$server->getL10N('settings', $lang);
// TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version
$potentialName = (string) $l->t('__language_name__');
- if($l->getLanguageCode() === $lang && substr($potentialName, 0, 1) !== '_') {//first check if the language name is in the translation file
+ if($l->getLanguageCode() === $lang && $potentialName[0] !== '_') {//first check if the language name is in the translation file
$ln = array('code' => $lang, 'name' => $potentialName);
} elseif ($lang === 'en') {
$ln = ['code' => $lang, 'name' => 'English (US)'];
diff --git a/lib/private/legacy/image.php b/lib/private/legacy/image.php
index 6ad9426a717..eeee3b24073 100644
--- a/lib/private/legacy/image.php
+++ b/lib/private/legacy/image.php
@@ -784,16 +784,16 @@ class OC_Image implements \OCP\IImage {
$color[1] = (($color[1] & 0xf800) >> 8) * 65536 + (($color[1] & 0x07e0) >> 3) * 256 + (($color[1] & 0x001f) << 3);
break;
case 8:
- $color = @unpack('n', $vide . substr($data, $p, 1));
+ $color = @unpack('n', $vide . ($data[$p] ?? ''));
$color[1] = (isset($palette[$color[1] + 1])) ? $palette[$color[1] + 1] : $palette[1];
break;
case 4:
- $color = @unpack('n', $vide . substr($data, floor($p), 1));
+ $color = @unpack('n', $vide . ($data[floor($p)] ?? ''));
$color[1] = ($p * 2) % 2 == 0 ? $color[1] >> 4 : $color[1] & 0x0F;
$color[1] = (isset($palette[$color[1] + 1])) ? $palette[$color[1] + 1] : $palette[1];
break;
case 1:
- $color = @unpack('n', $vide . substr($data, floor($p), 1));
+ $color = @unpack('n', $vide . ($data[floor($p)] ?? ''));
switch (($p * 8) % 8) {
case 0:
$color[1] = $color[1] >> 7;