Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
services
t3o sites
extensions.typo3.org
extensions.typo3.org
Commits
710bc55d
Commit
710bc55d
authored
Dec 03, 2021
by
Thomas Löffler
Browse files
[TASK] Introduce ValidVersionService and check for valid versions when generating XML
parent
eef1a6c8
Pipeline
#20471
passed with stages
in 5 minutes and 37 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extensions/ter/Classes/Api/ExtensionVersion.php
View file @
710bc55d
...
...
@@ -20,6 +20,7 @@ use T3o\Ter\Exception\NotFoundException;
use
T3o\Ter\Exception\NoUploadCommentException
;
use
T3o\Ter\Exception\UnauthorizedException
;
use
T3o\TerFe2\Service\LTSVersionService
;
use
T3o\TerFe2\Service\ValidExtensionVersionService
;
use
T3o\TerFe2\Utility\ArchiveUtility
;
use
T3o\TerFe2\Utility\CategoryUtility
;
use
T3o\TerFe2\Utility\VersionUtility
;
...
...
@@ -99,7 +100,7 @@ class ExtensionVersion
*/
public
function
isValidVersionNumber
():
bool
{
return
(
bool
)
preg_match
(
'/^(0|[1-9]\d{0,2})\.(0|[1-9]\d{0,2})\.(0|[1-9]\d{0,2})$/'
,
$this
->
version
);
return
ValidExtensionVersionService
::
isVersionStringValid
(
$this
->
version
);
// alternative (preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $version) !== false) {
}
...
...
extensions/ter_fe2/Classes/Service/ExtensionIndexService.php
View file @
710bc55d
...
...
@@ -123,6 +123,16 @@ class ExtensionIndexService implements LoggerAwareInterface
// Create the nested XML structure:
foreach
(
$extensionsAndVersionsArr
as
$extensionKey
=>
$extensionVersionsArr
)
{
$extensionHasMinimumOneValidVersion
=
false
;
foreach
(
$extensionVersionsArr
[
'versions'
]
as
$versionNumber
=>
$extensionVersionArr
)
{
if
(
ValidExtensionVersionService
::
isVersionStringValid
(
$versionNumber
))
{
$extensionHasMinimumOneValidVersion
=
true
;
break
;
}
}
if
(
!
$extensionHasMinimumOneValidVersion
)
{
continue
;
}
$extensionObj
=
$extensionsObj
->
appendChild
(
new
\
DOMElement
(
'extension'
));
$extensionObj
->
appendChild
(
new
\
DOMAttr
(
'extensionkey'
,
$extensionKey
));
$extensionObj
->
appendChild
(
...
...
@@ -133,6 +143,9 @@ class ExtensionIndexService implements LoggerAwareInterface
);
foreach
(
$extensionVersionsArr
[
'versions'
]
as
$versionNumber
=>
$extensionVersionArr
)
{
if
(
!
ValidExtensionVersionService
::
isVersionStringValid
(
$versionNumber
))
{
continue
;
}
$versionObj
=
$extensionObj
->
appendChild
(
new
\
DOMElement
(
'version'
));
$versionObj
->
appendChild
(
new
\
DOMAttr
(
'version'
,
(
string
)
$versionNumber
));
$versionObj
->
appendChild
(
new
\
DOMElement
(
'title'
,
$this
->
xmlentities
((
string
)
$extensionVersionArr
[
'title'
])));
...
...
extensions/ter_fe2/Classes/Service/ValidExtensionVersionService.php
0 → 100644
View file @
710bc55d
<?php
declare
(
strict_types
=
1
);
namespace
T3o\TerFe2\Service
;
final
class
ValidExtensionVersionService
{
public
const
VERSION_REGEX
=
'/^(0|[1-9]\d{0,2})\.(0|[1-9]\d{0,2})\.(0|[1-9]\d{0,2})$/'
;
public
static
function
isVersionStringValid
(
string
$versionString
):
bool
{
return
(
bool
)
preg_match
(
self
::
VERSION_REGEX
,
$versionString
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment