Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Check extension version number format
A false check in the TER API allowed to use arbitrary version strings, as soon as they start with the known `XXX.XXX.XXX` schema. This will be fixed in TER API. However, core as receiver should also validate the incoming data, before storing them in the database. Therefore, the same version number check, which is used in the TER API, is now also applied in the ExtensionXmlParser. Resolves: #96209 Releases: main, 11.5, 10.4 Change-Id: I487eed34c6b25a5e3841d5263b52b9a73aaf681a Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72484 Tested-by: core-ci <typo3@b13.com> Tested-by: Oliver Hader <oliver.hader@typo3.org> Tested-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Oliver Hader <oliver.hader@typo3.org> Reviewed-by: Oliver Bartsch <bo@cedev.de>
- Loading branch information
Showing
3 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
typo3/sysext/extensionmanager/Tests/Unit/Utility/Parser/ExtensionXmlPullParserTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Utility\Parser; | ||
|
||
use TYPO3\CMS\Extensionmanager\Utility\Parser\ExtensionXmlPullParser; | ||
use TYPO3\TestingFramework\Core\Unit\UnitTestCase; | ||
|
||
class ExtensionXmlPullParserTest extends UnitTestCase | ||
{ | ||
/** | ||
* @test | ||
* @dataProvider isValidVersionNumberDataProvider | ||
*/ | ||
public function isValidVersionNumber(string $versionNumber, bool $isValid): void | ||
{ | ||
$subject = $this->getAccessibleMock(ExtensionXmlPullParser::class, ['dummy']); | ||
$subject->_set('version', $versionNumber); | ||
|
||
self::assertEquals($isValid, $subject->isValidVersionNumber()); | ||
} | ||
|
||
public function isValidVersionNumberDataProvider(): \Generator | ||
{ | ||
yield 'Successive zeros are not allowed' => [ | ||
'00.2.3', | ||
false, | ||
]; | ||
yield 'Version premodifiers are not allowed' => [ | ||
'v11.2.3', | ||
false, | ||
]; | ||
yield 'Version postmodifiers are not allowed' => [ | ||
'11.2.3-pre-release', | ||
false, | ||
]; | ||
yield 'Characters are not allowed in general' => [ | ||
'11.a.3', | ||
false, | ||
]; | ||
yield 'More than three characters are not allowed' => [ | ||
'11.2.3999', | ||
false, | ||
]; | ||
yield 'Version most use three segements (major, minor, patch)' => [ | ||
'11.2', | ||
false, | ||
]; | ||
yield 'Successive separators are not allowed' => [ | ||
'11..2', | ||
false, | ||
]; | ||
yield 'Leading separator is not allowed' => [ | ||
'.11.2', | ||
false, | ||
]; | ||
yield 'Invalid separator' => [ | ||
'11-2-3', | ||
false, | ||
]; | ||
yield 'Missing separator' => [ | ||
'1123', | ||
false, | ||
]; | ||
yield 'Valid version number' => [ | ||
'11.2.3', | ||
true, | ||
]; | ||
} | ||
} |