31
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-06-08 16:22:20 +00:00

add check for allowed extension type (moved here from XMLManifest rules)

This commit is contained in:
Denis Ryabov 2021-06-27 00:27:14 +03:00
parent e5c59dc116
commit 31bb24d1dd

View File

@ -50,6 +50,15 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
*/
protected $description = 'COM_JEDCHECKER_INFO_XML_DESC';
/**
* List of JED extension types
*
* @var string[]
*/
protected $jedTypes = array(
'component', 'module', 'package', 'plugin'
);
/**
* Mapping of the plugin title prefix to the plugin group
*
@ -146,6 +155,12 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
if ($isTopLevel)
{
// JED allows components, modules, plugins, and packages (as a container) only
if (!in_array($type, $this->jedTypes, true))
{
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_TYPE_NOT_ACCEPTED', $type));
}
// NM3 - Listing name contains “module” or “plugin”
// (and other reserved words)
if (preg_match('/\b(?:module|plugin|component|template|extension|free)\b/i', $extensionName, $match))