From 372ea55ad7986b18c2648e41e587fde88f03fa3d Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Tue, 2 Feb 2021 14:56:56 +0300 Subject: [PATCH 01/22] - fixed loading of language file - check manifest file do exist - check naming rules - drop Joomla!1.5 support ("install" root element) --- .../language/en-GB/en-GB.com_jedchecker.ini | 9 + .../libraries/rules/xmlinfo.php | 158 +++++++++++++++--- 2 files changed, 143 insertions(+), 24 deletions(-) diff --git a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini index 7231b32..918481f 100644 --- a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini +++ b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini @@ -43,6 +43,15 @@ COM_JEDCHECKER_INFO_XML_DESC="The install name of your extension must match your COM_JEDCHECKER_INFO_XML_NAME_XML="The name tag in this file is: %s" COM_JEDCHECKER_INFO_XML_VERSION_XML="Version tag has the value: %s" COM_JEDCHECKER_INFO_XML_CREATIONDATE_XML="The creationDate tag has the value: %s" +COM_JEDCHECKER_INFO_XML_NO_MANIFEST="No manifest file found" +COM_JEDCHECKER_INFO_XML_NAME_MODULE_PLUGIN="Listing name contains 'module' or 'plugin'" +COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS="Keywords such as module, plugin or template are considered reserved words and can't be used in the extension names" +COM_JEDCHECKER_INFO_XML_NAME_VERSION="Version in name/title" +COM_JEDCHECKER_INFO_XML_NAME_JOOMLA="An extension name can't start with the word 'Joomla'" +COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE="Extensions that use 'Joomla' or a derivative of Joomla in the extension name need to be licensed by OSM" +COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE="Extensions that use 'Joomla' or a derivative of Joomla in the domain name need to be licensed by OSM" +COM_JEDCHECKER_INFO_XML_NAME_ADMIN_MENU="The admin menu name '%1$s' isn't the same as the extension name '%2$s'" +COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT="The name of the plugin must comply with the JED naming conventions in the form '{Type} - {Extension Name}'" COM_JEDCHECKER_RULE_PH1="PHP Headers missing GPL License Notice" COM_JEDCHECKER_RULE_PH1_DESC="A notice is required on each PHP file stating that the file is licensed GPL (or other compatible accepted license). For more information, please click here." COM_JEDCHECKER_ERROR_GPL_NOT_FOUND="GPL or compatible license was not found" diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index b4037be..9d3a44e 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -57,11 +57,21 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule // Find all XML files of the extension $files = JFolder::files($this->basedir, '.xml$', true, true); + $manifestFound = false; + // Iterate through all the xml files foreach ($files as $file) { // Try to find the license - $this->find($file); + if ($this->find($file)) + { + $manifestFound = true; + } + } + + if (!$manifestFound) + { + $this->report->addError('', JText::_('COM_JEDCHECKER_INFO_XML_NO_MANIFEST')); } } @@ -70,51 +80,151 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule * * @param string $file - The path to the file * - * @return boolean True if the license was found, otherwise False. + * @return boolean True if the manifest file was found, otherwise False. */ protected function find($file) { $xml = JFactory::getXml($file); - // Get all the info about the file - $folder_info = pathinfo($file); - - // Get the folder path - $folder_path = $folder_info['dirname']; - - // Get the folder name - $folder_name = $folder_info['dirname']; - $folder_name_exploded = explode(DIRECTORY_SEPARATOR,$folder_name); - if ( is_array($folder_name_exploded) ) { - $folder_name = end($folder_name_exploded); - } - - // Load the language of the extension (if any) - $lang = JFactory::getLanguage(); - $lang->load($folder_name,$folder_path); - // Failed to parse the xml file. // Assume that this is not a extension manifest if (!$xml) { - return true; + return false; } // Check if this is an extension manifest - // 1.5 uses 'install', 1.6 uses 'extension' - if ($xml->getName() != 'install' && $xml->getName() != 'extension') + // 1.5 uses 'install', 1.6+ uses 'extension' + if ($xml->getName() !== 'extension') { - return true; + return false; + } + + // Get extension name (element) + $type = (string) $xml['type']; + if (isset($xml->element)) + { + $extension = (string) $xml->element; + } + else + { + $extension = (string) $xml->name; + foreach ($xml->files->children as $child) + { + if (isset($child[$type])) + { + $extension = (string) $child[$type]; + } + } + } + $extension = strtolower(JFilterInput::getInstance()->clean($extension, 'cmd')); + if ($type === 'component' && strpos($extension, 'com_') !== 0) + { + $extension = 'com_' . $extension; + } + + // Load the language of the extension (if any) + $lang = JFactory::getLanguage(); + + // search for .sys.ini translation file + $lang_dir = dirname($file); + $lang_tag = 'en-GB'; // $lang->getDefault(); + + $lookup_lang_dirs = array(); + if (isset($xml->administration->files['folder'])) + { + $lookup_lang_dirs[] = $xml->administration->files['folder'] . '/language/' . $lang_tag; + } + if (isset($xml->files['folder'])) + { + $lookup_lang_dirs[] = $xml->files['folder'] . '/language/' . $lang_tag; + } + if (isset($xml->administration->languages['folder'])) + { + $lookup_lang_dirs[] = $xml->administration->languages['folder']; + } + if (isset($xml->languages['folder'])) + { + $lookup_lang_dirs[] = $xml->languages['folder']; + } + $lookup_lang_dirs[] = ''; + + foreach ($lookup_lang_dirs as $dir) + { + $lang_sys_file = + $lang_dir . '/' . + ($dir === '' ? '' : trim($dir, '/') . '/') . + $lang_tag. '.' . $extension . '.sys.ini'; + if (is_file($lang_sys_file)) + { + $loadLanguage = new ReflectionMethod($lang, 'loadLanguage'); + $loadLanguage->setAccessible(true); + $loadLanguage->invoke($lang, $lang_sys_file, $extension); + break; + } } // Get the real extension's name now that the language has been loaded - (string) $extension_name = $lang->_($xml->name); + $extension_name = $lang->_((string) $xml->name); $info[] = JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_XML', $extension_name); $info[] = JText::sprintf('COM_JEDCHECKER_INFO_XML_VERSION_XML', (string) $xml->version); $info[] = JText::sprintf('COM_JEDCHECKER_INFO_XML_CREATIONDATE_XML', (string) $xml->creationDate); + $this->report->addInfo($file, implode('
', $info)); + // NM3 - Listing name contains “module” or “plugin” + if (preg_match('/\b(?:module|plugin)\b/i', $extension_name)) + { + $this->report->addError($file, JText::_('COM_JEDCHECKER_INFO_XML_NAME_MODULE_PLUGIN')); + } + if (stripos($extension_name, 'template') !== false) + { + $this->report->addWarning($file, JText::_('COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS')); + } + + // NM5 - Version in name/title + if (preg_match('/(?:\bversion\b|\d\.\d)/i', $extension_name)) + { + $this->report->addError($file, JText::_('COM_JEDCHECKER_INFO_XML_NAME_VERSION')); + } + + if (stripos($extension_name, 'joomla') === 0) + { + $this->report->addError($file, JText::_('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA')); + } + elseif (stripos($extension_name, 'joom') !== false) + { + $this->report->addWarning($file, JText::_('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE')); + } + + $url = (string)$xml->authorUrl; + if (stripos($url, 'joom') !== false) + { + $domain = (strpos($url, '//') === false) ? $url : parse_url(trim($url), PHP_URL_HOST); + if (stripos($domain, 'joom') !== false) { + $this->report->addWarning($file, JText::_('COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE')); + } + } + + if ($type === 'component' && isset($xml->administration->menu)) + { + $menu_name = $lang->_((string) $xml->administration->menu); + if ($extension_name !== $menu_name) + { + $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_ADMIN_MENU', $menu_name, $extension_name)); + } + } + + if ($type === 'plugin') + { + $group = (string) $xml['group']; + if (strpos($extension_name, ucfirst($group) . ' - ') !== 0) + { + $this->report->addWarning($file, JText::_('COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT')); + } + } + // All checks passed. Return true return true; } From 070b22caaef4e7643dac2cec10fa4289bbacc2e1 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Tue, 2 Feb 2021 15:36:52 +0300 Subject: [PATCH 02/22] one more directory to lookup for language file --- .../com_jedchecker/libraries/rules/xmlinfo.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index 9d3a44e..0b30250 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -133,19 +133,20 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule $lookup_lang_dirs = array(); if (isset($xml->administration->files['folder'])) { - $lookup_lang_dirs[] = $xml->administration->files['folder'] . '/language/' . $lang_tag; + $lookup_lang_dirs[] = trim($xml->administration->files['folder'], '/') . '/language/' . $lang_tag; } if (isset($xml->files['folder'])) { - $lookup_lang_dirs[] = $xml->files['folder'] . '/language/' . $lang_tag; + $lookup_lang_dirs[] = trim($xml->files['folder'], '/') . '/language/' . $lang_tag; } + $lookup_lang_dirs[] = 'language/' . $lang_tag; if (isset($xml->administration->languages['folder'])) { - $lookup_lang_dirs[] = $xml->administration->languages['folder']; + $lookup_lang_dirs[] = trim($xml->administration->languages['folder'], '/'); } if (isset($xml->languages['folder'])) { - $lookup_lang_dirs[] = $xml->languages['folder']; + $lookup_lang_dirs[] = trim($xml->languages['folder'], '/'); } $lookup_lang_dirs[] = ''; From e83378549453be304765d72454b64f5dcb45f62a Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 18 Feb 2021 15:13:51 +0300 Subject: [PATCH 03/22] fix paths for language dirs --- .../components/com_jedchecker/libraries/rules/xmlinfo.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index 0b30250..34282ad 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -142,11 +142,11 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule $lookup_lang_dirs[] = 'language/' . $lang_tag; if (isset($xml->administration->languages['folder'])) { - $lookup_lang_dirs[] = trim($xml->administration->languages['folder'], '/'); + $lookup_lang_dirs[] = trim($xml->administration->languages['folder'], '/') . '/' . $lang_tag; } if (isset($xml->languages['folder'])) { - $lookup_lang_dirs[] = trim($xml->languages['folder'], '/'); + $lookup_lang_dirs[] = trim($xml->languages['folder'], '/') . '/' . $lang_tag; } $lookup_lang_dirs[] = ''; @@ -154,7 +154,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule { $lang_sys_file = $lang_dir . '/' . - ($dir === '' ? '' : trim($dir, '/') . '/') . + ($dir === '' ? '' : $dir . '/') . $lang_tag. '.' . $extension . '.sys.ini'; if (is_file($lang_sys_file)) { From f536d77cc3f29e863f91ab014fa37be01bc4d78a Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 18 Feb 2021 15:24:28 +0300 Subject: [PATCH 04/22] fix matching of plugin group in title (remove spaces for "Action Log", "Quick Icons", etc.) --- .../components/com_jedchecker/libraries/rules/xmlinfo.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index 34282ad..285f565 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -219,8 +219,9 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule if ($type === 'plugin') { - $group = (string) $xml['group']; - if (strpos($extension_name, ucfirst($group) . ' - ') !== 0) + $parts = explode(' - ', $extension_name, 2); + $extension_name_group = isset($parts[1]) ? strtolower(preg_replace('/\s/', '', $parts[0])) : false; + if ($extension_name_group !== (string) $xml['group']) { $this->report->addWarning($file, JText::_('COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT')); } From 216e4820092f509f824c78aa2c052fd6e559be7b Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 18 Feb 2021 15:25:03 +0300 Subject: [PATCH 05/22] display plugin name in the message (for packages with multiple plugins) --- .../com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini | 2 +- .../components/com_jedchecker/libraries/rules/xmlinfo.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini index 918481f..655f058 100644 --- a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini +++ b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini @@ -51,7 +51,7 @@ COM_JEDCHECKER_INFO_XML_NAME_JOOMLA="An extension name can't start with the word COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE="Extensions that use 'Joomla' or a derivative of Joomla in the extension name need to be licensed by OSM" COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE="Extensions that use 'Joomla' or a derivative of Joomla in the domain name need to be licensed by OSM" COM_JEDCHECKER_INFO_XML_NAME_ADMIN_MENU="The admin menu name '%1$s' isn't the same as the extension name '%2$s'" -COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT="The name of the plugin must comply with the JED naming conventions in the form '{Type} - {Extension Name}'" +COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT="The name of the plugin ('%s') must comply with the JED naming conventions in the form '{Type} - {Extension Name}'" COM_JEDCHECKER_RULE_PH1="PHP Headers missing GPL License Notice" COM_JEDCHECKER_RULE_PH1_DESC="A notice is required on each PHP file stating that the file is licensed GPL (or other compatible accepted license). For more information, please click here." COM_JEDCHECKER_ERROR_GPL_NOT_FOUND="GPL or compatible license was not found" diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index 285f565..836aed1 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -223,7 +223,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule $extension_name_group = isset($parts[1]) ? strtolower(preg_replace('/\s/', '', $parts[0])) : false; if ($extension_name_group !== (string) $xml['group']) { - $this->report->addWarning($file, JText::_('COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT')); + $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT', $extension_name)); } } From 5fafb747f0b7ed00c12cc9db93c7067a319e2178 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 00:06:02 +0300 Subject: [PATCH 06/22] fix loop through children nodes --- .../com_jedchecker/libraries/rules/xmlinfo.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index 836aed1..5fea42c 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -109,11 +109,14 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule else { $extension = (string) $xml->name; - foreach ($xml->files->children as $child) + if (isset($xml->files)) { - if (isset($child[$type])) + foreach ($xml->files->children() as $child) { - $extension = (string) $child[$type]; + if (isset($child[$type])) + { + $extension = (string) $child[$type]; + } } } } From 75b6aa0f47d3ed1b99db46c3416ca6d15fa969f3 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 00:16:31 +0300 Subject: [PATCH 07/22] fix loading of language file --- .../libraries/rules/xmlinfo.php | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index 5fea42c..21cef5f 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -126,6 +126,11 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule $extension = 'com_' . $extension; } + if ($type === 'plugin' && isset($xml['group'])) + { + $extension = 'plg_' . $xml['group'] . '_' . $extension; + } + // Load the language of the extension (if any) $lang = JFactory::getLanguage(); @@ -134,25 +139,49 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule $lang_tag = 'en-GB'; // $lang->getDefault(); $lookup_lang_dirs = array(); + if (isset($xml->administration->files['folder'])) { $lookup_lang_dirs[] = trim($xml->administration->files['folder'], '/') . '/language/' . $lang_tag; } + if (isset($xml->files['folder'])) { $lookup_lang_dirs[] = trim($xml->files['folder'], '/') . '/language/' . $lang_tag; } + $lookup_lang_dirs[] = 'language/' . $lang_tag; - if (isset($xml->administration->languages['folder'])) + + if (isset($xml->administration->languages)) { - $lookup_lang_dirs[] = trim($xml->administration->languages['folder'], '/') . '/' . $lang_tag; + $folder = trim($xml->administration->languages['folder'], '/'); + + foreach ($xml->administration->languages->language as $language) + { + if (trim($language['tag']) === $lang_tag) + { + $lookup_lang_dirs[] = trim($folder . '/' . dirname($language), '/'); + } + } } - if (isset($xml->languages['folder'])) + + if (isset($xml->languages)) { - $lookup_lang_dirs[] = trim($xml->languages['folder'], '/') . '/' . $lang_tag; + $folder = trim($xml->languages['folder'], '/'); + + foreach ($xml->languages->language as $language) + { + if (trim($language['tag']) === $lang_tag) + { + $lookup_lang_dirs[] = trim($folder . '/' . dirname($language), '/'); + } + } } + $lookup_lang_dirs[] = ''; + $lookup_lang_dirs = array_unique($lookup_lang_dirs); + foreach ($lookup_lang_dirs as $dir) { $lang_sys_file = From 5771fb0203003fe0ae215e69e74fa2168be26b22 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 00:20:09 +0300 Subject: [PATCH 08/22] add list of alternative plugin group names --- .../com_jedchecker/libraries/rules/xmlinfo.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index 21cef5f..c3e3921 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -47,6 +47,18 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule */ protected $description = 'COM_JEDCHECKER_INFO_XML_DESC'; + /** + * Mapping of the plugin title prefix to the plugin group + * + * @var string[] + */ + protected $pluginsGroupMap = array( + 'button' => 'editors-xtd', + 'editor' => 'editors', + 'smartsearch' => 'finder', + 'twofactorauthentication' => 'twofactorauth' + ); + /** * Initiates the search and check * @@ -253,7 +265,11 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule { $parts = explode(' - ', $extension_name, 2); $extension_name_group = isset($parts[1]) ? strtolower(preg_replace('/\s/', '', $parts[0])) : false; - if ($extension_name_group !== (string) $xml['group']) + $group = (string) $xml['group']; + + if ($extension_name_group !== $group && $extension_name_group !== str_replace('-', '', $group) + && !(isset($this->pluginsGroupMap[$extension_name_group]) && $this->pluginsGroupMap[$extension_name_group] === $group) + ) { $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT', $extension_name)); } From c11c23c15a093df5f9b0c738f245d5a05d1ac0c0 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 00:24:48 +0300 Subject: [PATCH 09/22] check domain name against the list of approved domains --- .../language/en-GB/en-GB.com_jedchecker.ini | 2 +- .../libraries/rules/xmlinfo.php | 15 +++++- .../rules/xmlinfo/approved-domains.txt | 46 +++++++++++++++++++ 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 administrator/components/com_jedchecker/libraries/rules/xmlinfo/approved-domains.txt diff --git a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini index 655f058..a8717ec 100644 --- a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini +++ b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini @@ -49,7 +49,7 @@ COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS="Keywords such as module, plugin COM_JEDCHECKER_INFO_XML_NAME_VERSION="Version in name/title" COM_JEDCHECKER_INFO_XML_NAME_JOOMLA="An extension name can't start with the word 'Joomla'" COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE="Extensions that use 'Joomla' or a derivative of Joomla in the extension name need to be licensed by OSM" -COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE="Extensions that use 'Joomla' or a derivative of Joomla in the domain name need to be licensed by OSM" +COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE="Extensions that use 'Joomla' or a derivative of Joomla in the domain name ('%s') need to be licensed by OSM" COM_JEDCHECKER_INFO_XML_NAME_ADMIN_MENU="The admin menu name '%1$s' isn't the same as the extension name '%2$s'" COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT="The name of the plugin ('%s') must comply with the JED naming conventions in the form '{Type} - {Extension Name}'" COM_JEDCHECKER_RULE_PH1="PHP Headers missing GPL License Notice" diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index c3e3921..b010207 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -247,8 +247,19 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule if (stripos($url, 'joom') !== false) { $domain = (strpos($url, '//') === false) ? $url : parse_url(trim($url), PHP_URL_HOST); - if (stripos($domain, 'joom') !== false) { - $this->report->addWarning($file, JText::_('COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE')); + + if (stripos($domain, 'joom') !== false) + { + // Remove "www." subdomain prefix + $domain = preg_replace('/^www\./', '', $domain); + + // Approved domains from https://tm.joomla.org/approved-domains.html + $approvedDomains = file(__DIR__ . '/xmlinfo/approved-domains.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + + if (!in_array($domain, $approvedDomains, true)) + { + $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE', $url)); + } } } diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo/approved-domains.txt b/administrator/components/com_jedchecker/libraries/rules/xmlinfo/approved-domains.txt new file mode 100644 index 0000000..6e8c234 --- /dev/null +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo/approved-domains.txt @@ -0,0 +1,46 @@ +joomla.org + +hotjoomlatemplates.com +joomlanl.nl +joomla-templates.com +joomla-update.org +joomlaportal.ru +joomlavia.com +joomlatranslate.com +joomlamarketplace.online +hotjoomlatemplates.com +joomlatema.net +joomla.it +joomlaalger.org +joomla.cafe +joomlatwincities.org +joomlausersnj.com +joomlausersnyc.org +joomlact.org +joomlachicagonorth.com +joomlanh.org +joomlanh.org +joomlacarioca.com.br +novajoomla.com +joomlazur.com +joomladallas.org +joomlariodejaneiro.com.br +joomlatenerife.org +joomlage.com +joomlamadrid.org +joomschool.com +usingjoomla.com +joomla.cymru +joomlavigo.es +jug-warszawa.joomla.pl +joomlavalencia.net +jug-silesia.joomla.pl +jug-poznan.joomla.pl +joomla-canberra.org.au +joomlapay.com +joomlalondon.co.uk +mobilejoomla.com/ +myjoomla.com +joomlacontenteditor.net +joomlalabs.com +modernjoomla.com From 2cae2d0deb4287cb3ae2fa3e4d561a8b7325277d Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 00:44:53 +0300 Subject: [PATCH 10/22] show node content in errors/warnings messages --- .../language/en-GB/en-GB.com_jedchecker.ini | 10 +++++----- .../com_jedchecker/libraries/rules/xmlinfo.php | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini index a8717ec..268791b 100644 --- a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini +++ b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini @@ -44,11 +44,11 @@ COM_JEDCHECKER_INFO_XML_NAME_XML="The name tag in this file is: %s" COM_JEDCHECKER_INFO_XML_VERSION_XML="Version tag has the value: %s" COM_JEDCHECKER_INFO_XML_CREATIONDATE_XML="The creationDate tag has the value: %s" COM_JEDCHECKER_INFO_XML_NO_MANIFEST="No manifest file found" -COM_JEDCHECKER_INFO_XML_NAME_MODULE_PLUGIN="Listing name contains 'module' or 'plugin'" -COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS="Keywords such as module, plugin or template are considered reserved words and can't be used in the extension names" -COM_JEDCHECKER_INFO_XML_NAME_VERSION="Version in name/title" -COM_JEDCHECKER_INFO_XML_NAME_JOOMLA="An extension name can't start with the word 'Joomla'" -COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE="Extensions that use 'Joomla' or a derivative of Joomla in the extension name need to be licensed by OSM" +COM_JEDCHECKER_INFO_XML_NAME_MODULE_PLUGIN="Listing name ('%s') contains 'module' or 'plugin'" +COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS="Keywords such as module, plugin or template are considered reserved words and can't be used in the extension names ('%s')" +COM_JEDCHECKER_INFO_XML_NAME_VERSION="Version in name/title ('%s')" +COM_JEDCHECKER_INFO_XML_NAME_JOOMLA="An extension name ('%s') can't start with the word 'Joomla'" +COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE="Extensions that use 'Joomla' or a derivative of Joomla in the extension name ('%s') need to be licensed by OSM" COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE="Extensions that use 'Joomla' or a derivative of Joomla in the domain name ('%s') need to be licensed by OSM" COM_JEDCHECKER_INFO_XML_NAME_ADMIN_MENU="The admin menu name '%1$s' isn't the same as the extension name '%2$s'" COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT="The name of the plugin ('%s') must comply with the JED naming conventions in the form '{Type} - {Extension Name}'" diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index b010207..d48e834 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -221,26 +221,26 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule // NM3 - Listing name contains “module” or “plugin” if (preg_match('/\b(?:module|plugin)\b/i', $extension_name)) { - $this->report->addError($file, JText::_('COM_JEDCHECKER_INFO_XML_NAME_MODULE_PLUGIN')); + $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_MODULE_PLUGIN', $extension_name)); } if (stripos($extension_name, 'template') !== false) { - $this->report->addWarning($file, JText::_('COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS')); + $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS', $extension_name)); } // NM5 - Version in name/title if (preg_match('/(?:\bversion\b|\d\.\d)/i', $extension_name)) { - $this->report->addError($file, JText::_('COM_JEDCHECKER_INFO_XML_NAME_VERSION')); + $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_VERSION', $extension_name)); } if (stripos($extension_name, 'joomla') === 0) { - $this->report->addError($file, JText::_('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA')); + $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA', $extension_name)); } elseif (stripos($extension_name, 'joom') !== false) { - $this->report->addWarning($file, JText::_('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE')); + $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE', $extension_name)); } $url = (string)$xml->authorUrl; From 72b55455287afe8bf3dce73dd064a839bb089d44 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 11 Mar 2021 00:59:05 +0300 Subject: [PATCH 11/22] change translation string --- .../com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini index 268791b..3c10c32 100644 --- a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini +++ b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini @@ -49,7 +49,7 @@ COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS="Keywords such as module, plugin COM_JEDCHECKER_INFO_XML_NAME_VERSION="Version in name/title ('%s')" COM_JEDCHECKER_INFO_XML_NAME_JOOMLA="An extension name ('%s') can't start with the word 'Joomla'" COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE="Extensions that use 'Joomla' or a derivative of Joomla in the extension name ('%s') need to be licensed by OSM" -COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE="Extensions that use 'Joomla' or a derivative of Joomla in the domain name ('%s') need to be licensed by OSM" +COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE="Domain names that use 'Joomla' or a derivative of Joomla ('%s') need to be licensed by OSM" COM_JEDCHECKER_INFO_XML_NAME_ADMIN_MENU="The admin menu name '%1$s' isn't the same as the extension name '%2$s'" COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT="The name of the plugin ('%s') must comply with the JED naming conventions in the form '{Type} - {Extension Name}'" COM_JEDCHECKER_RULE_PH1="PHP Headers missing GPL License Notice" From 6091c866c0a60816e39bba2df716f83aa544e2b3 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 11 Mar 2021 01:01:14 +0300 Subject: [PATCH 12/22] commenting the code --- .../components/com_jedchecker/libraries/rules/xmlinfo.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index d48e834..3e6e65d 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -113,6 +113,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule } // Get extension name (element) + $type = (string) $xml['type']; if (isset($xml->element)) { @@ -194,6 +195,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule $lookup_lang_dirs = array_unique($lookup_lang_dirs); + // Looking for language file in specified directories foreach ($lookup_lang_dirs as $dir) { $lang_sys_file = @@ -223,6 +225,8 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule { $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_MODULE_PLUGIN', $extension_name)); } + + // The "template" is reserved keyword if (stripos($extension_name, 'template') !== false) { $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS', $extension_name)); From 7a36ce7582bc52923f94823a376cc2b32e950d26 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 11 Mar 2021 01:04:23 +0300 Subject: [PATCH 13/22] EOL at the end of language file (to simplify merging) --- .../com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini index 3c10c32..b9f93d9 100644 --- a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini +++ b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini @@ -86,4 +86,4 @@ COM_JEDCHECKER_ERROR_XML_UPDATE_SERVER_LINK_NOT_FOUND="Update Server link not fo COM_JEDCHECKER_INFO_XML_UPDATE_SERVER_LINK="The Update Server link in this XML file is: %s" COM_JEDCHECKER_DELETE_FAILED="Can't delete temporary folder" COM_JEDCHECKER_DELETE_SUCCESS="Temporary folder deleted!" -COM_JEDCHECKER_EMPTY_UPLOAD_FIELD="Please, select a zipped file to be uploaded" \ No newline at end of file +COM_JEDCHECKER_EMPTY_UPLOAD_FIELD="Please, select a zipped file to be uploaded" From d102979258b7f067a7cc7a9ff1ae01cbfaf7139f Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 11 Mar 2021 01:56:04 +0300 Subject: [PATCH 14/22] add some comments --- .../libraries/rules/xmlinfo.php | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index 3e6e65d..c2808d4 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -112,15 +112,19 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule return false; } - // Get extension name (element) - + // Get extension type $type = (string) $xml['type']; + + // Get extension's element name (simulates work of Joomla's installer) + + // Firstly, check for node if (isset($xml->element)) { $extension = (string) $xml->element; } else { + // Otherwise, use node or plugin/module attribute in the section $extension = (string) $xml->name; if (isset($xml->files)) { @@ -133,13 +137,18 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule } } } + + // Filter extension's element name $extension = strtolower(JFilterInput::getInstance()->clean($extension, 'cmd')); + + // Component's element name starts with com_ if ($type === 'component' && strpos($extension, 'com_') !== 0) { $extension = 'com_' . $extension; } - if ($type === 'plugin' && isset($xml['group'])) + // Plugin's element name starts with com_ + if ($type === 'plugin' && isset($xml['group']) && strpos($extension, 'plg_') !== 0) { $extension = 'plg_' . $xml['group'] . '_' . $extension; } @@ -151,6 +160,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule $lang_dir = dirname($file); $lang_tag = 'en-GB'; // $lang->getDefault(); + // Populate list of directories to look for $lookup_lang_dirs = array(); if (isset($xml->administration->files['folder'])) @@ -240,10 +250,12 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule if (stripos($extension_name, 'joomla') === 0) { + // An extension name can't start with the word "Joomla" $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA', $extension_name)); } elseif (stripos($extension_name, 'joom') !== false) { + // Extensions that use "Joomla" or a derivative of Joomla in the extension name need to be licensed by OSM $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE', $extension_name)); } @@ -262,6 +274,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule if (!in_array($domain, $approvedDomains, true)) { + // Extensions that use "Joomla" or a derivative of Joomla in the domain name need to be licensed by OSM $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE', $url)); } } @@ -270,6 +283,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule if ($type === 'component' && isset($xml->administration->menu)) { $menu_name = $lang->_((string) $xml->administration->menu); + // Do name the Component's admin menu the same as the extension name if ($extension_name !== $menu_name) { $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_ADMIN_MENU', $menu_name, $extension_name)); @@ -278,6 +292,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule if ($type === 'plugin') { + // The name of your plugin must comply with the JED naming conventions - plugins in the form “{Type} - {Extension Name}”. $parts = explode(' - ', $extension_name, 2); $extension_name_group = isset($parts[1]) ? strtolower(preg_replace('/\s/', '', $parts[0])) : false; $group = (string) $xml['group']; From 65fe32b164e56cfa4013832dbdbd1295bdd65294 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 11 Mar 2021 10:40:52 +0300 Subject: [PATCH 15/22] replace check against a preinstalled domains list by the link to the Joomla! Trademark Approval Registry page --- .../language/en-GB/en-GB.com_jedchecker.ini | 2 +- .../libraries/rules/xmlinfo.php | 13 +----- .../rules/xmlinfo/approved-domains.txt | 46 ------------------- 3 files changed, 3 insertions(+), 58 deletions(-) delete mode 100644 administrator/components/com_jedchecker/libraries/rules/xmlinfo/approved-domains.txt diff --git a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini index b9f93d9..6742542 100644 --- a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini +++ b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini @@ -49,7 +49,7 @@ COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS="Keywords such as module, plugin COM_JEDCHECKER_INFO_XML_NAME_VERSION="Version in name/title ('%s')" COM_JEDCHECKER_INFO_XML_NAME_JOOMLA="An extension name ('%s') can't start with the word 'Joomla'" COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE="Extensions that use 'Joomla' or a derivative of Joomla in the extension name ('%s') need to be licensed by OSM" -COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE="Domain names that use 'Joomla' or a derivative of Joomla ('%s') need to be licensed by OSM" +COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE="Domain names that use 'Joomla' or a derivative of Joomla ('%1$s') need to be licensed by OSM. Please, check your domain name is listed on the Joomla! Trademark Approval Registry page." COM_JEDCHECKER_INFO_XML_NAME_ADMIN_MENU="The admin menu name '%1$s' isn't the same as the extension name '%2$s'" COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT="The name of the plugin ('%s') must comply with the JED naming conventions in the form '{Type} - {Extension Name}'" COM_JEDCHECKER_RULE_PH1="PHP Headers missing GPL License Notice" diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index c2808d4..a03e65d 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -266,17 +266,8 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule if (stripos($domain, 'joom') !== false) { - // Remove "www." subdomain prefix - $domain = preg_replace('/^www\./', '', $domain); - - // Approved domains from https://tm.joomla.org/approved-domains.html - $approvedDomains = file(__DIR__ . '/xmlinfo/approved-domains.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); - - if (!in_array($domain, $approvedDomains, true)) - { - // Extensions that use "Joomla" or a derivative of Joomla in the domain name need to be licensed by OSM - $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE', $url)); - } + // Extensions that use "Joomla" or a derivative of Joomla in the domain name need to be licensed by OSM + $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE', $url, 'https://tm.joomla.org/approved-domains.html')); } } diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo/approved-domains.txt b/administrator/components/com_jedchecker/libraries/rules/xmlinfo/approved-domains.txt deleted file mode 100644 index 6e8c234..0000000 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo/approved-domains.txt +++ /dev/null @@ -1,46 +0,0 @@ -joomla.org - -hotjoomlatemplates.com -joomlanl.nl -joomla-templates.com -joomla-update.org -joomlaportal.ru -joomlavia.com -joomlatranslate.com -joomlamarketplace.online -hotjoomlatemplates.com -joomlatema.net -joomla.it -joomlaalger.org -joomla.cafe -joomlatwincities.org -joomlausersnj.com -joomlausersnyc.org -joomlact.org -joomlachicagonorth.com -joomlanh.org -joomlanh.org -joomlacarioca.com.br -novajoomla.com -joomlazur.com -joomladallas.org -joomlariodejaneiro.com.br -joomlatenerife.org -joomlage.com -joomlamadrid.org -joomschool.com -usingjoomla.com -joomla.cymru -joomlavigo.es -jug-warszawa.joomla.pl -joomlavalencia.net -jug-silesia.joomla.pl -jug-poznan.joomla.pl -joomla-canberra.org.au -joomlapay.com -joomlalondon.co.uk -mobilejoomla.com/ -myjoomla.com -joomlacontenteditor.net -joomlalabs.com -modernjoomla.com From 0869a0cecb44ede9ffd2907d8f284a8a3d5d216c Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Mar 2021 15:11:59 +0300 Subject: [PATCH 16/22] fix comment text --- .../components/com_jedchecker/libraries/rules/xmlinfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index a03e65d..c60abcc 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -147,7 +147,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule $extension = 'com_' . $extension; } - // Plugin's element name starts with com_ + // Plugin's element name starts with plg_ if ($type === 'plugin' && isset($xml['group']) && strpos($extension, 'plg_') !== 0) { $extension = 'plg_' . $xml['group'] . '_' . $extension; From ab96c035ad9f984b5fc28db423ee5de8ce66195b Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Mar 2021 15:13:28 +0300 Subject: [PATCH 17/22] a "greedy" match (by @Llewellynvdm) --- .../components/com_jedchecker/libraries/rules/xmlinfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index c60abcc..5adff47 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -231,7 +231,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule $this->report->addInfo($file, implode('
', $info)); // NM3 - Listing name contains “module” or “plugin” - if (preg_match('/\b(?:module|plugin)\b/i', $extension_name)) + if (preg_match('/(?:module|plugin)/i', $extension_name)) { $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_MODULE_PLUGIN', $extension_name)); } From 0d2310f75d2de0a3f2a390c138a6543fdb559cc8 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Mar 2021 15:22:09 +0300 Subject: [PATCH 18/22] simplify regex --- .../components/com_jedchecker/libraries/rules/xmlinfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index 5adff47..fc2119b 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -231,7 +231,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule $this->report->addInfo($file, implode('
', $info)); // NM3 - Listing name contains “module” or “plugin” - if (preg_match('/(?:module|plugin)/i', $extension_name)) + if (preg_match('/module|plugin/i', $extension_name)) { $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_MODULE_PLUGIN', $extension_name)); } From e2d61929f94e5cc5a787807846cf1b071b0f403a Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sun, 4 Apr 2021 13:50:33 +0300 Subject: [PATCH 19/22] Joomla! code style fixes --- .../libraries/rules/xmlinfo.php | 84 ++++++++++--------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index fc2119b..1698465 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -20,7 +20,7 @@ require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php'; /** * class JedcheckerRulesXMLinfo * - * This class searches all xml manifestes for specific tags + * This class searches all xml manifests for specific tags * * @since 1.0 */ @@ -126,6 +126,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule { // Otherwise, use node or plugin/module attribute in the section $extension = (string) $xml->name; + if (isset($xml->files)) { foreach ($xml->files->children() as $child) @@ -156,24 +157,24 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule // Load the language of the extension (if any) $lang = JFactory::getLanguage(); - // search for .sys.ini translation file - $lang_dir = dirname($file); - $lang_tag = 'en-GB'; // $lang->getDefault(); + // Search for .sys.ini translation file + $langDir = dirname($file); + $langTag = 'en-GB'; // $lang->getDefault(); // Populate list of directories to look for - $lookup_lang_dirs = array(); + $lookupLangDirs = array(); if (isset($xml->administration->files['folder'])) { - $lookup_lang_dirs[] = trim($xml->administration->files['folder'], '/') . '/language/' . $lang_tag; + $lookupLangDirs[] = trim($xml->administration->files['folder'], '/') . '/language/' . $langTag; } if (isset($xml->files['folder'])) { - $lookup_lang_dirs[] = trim($xml->files['folder'], '/') . '/language/' . $lang_tag; + $lookupLangDirs[] = trim($xml->files['folder'], '/') . '/language/' . $langTag; } - $lookup_lang_dirs[] = 'language/' . $lang_tag; + $lookupLangDirs[] = 'language/' . $langTag; if (isset($xml->administration->languages)) { @@ -181,9 +182,9 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule foreach ($xml->administration->languages->language as $language) { - if (trim($language['tag']) === $lang_tag) + if (trim($language['tag']) === $langTag) { - $lookup_lang_dirs[] = trim($folder . '/' . dirname($language), '/'); + $lookupLangDirs[] = trim($folder . '/' . dirname($language), '/'); } } } @@ -194,72 +195,73 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule foreach ($xml->languages->language as $language) { - if (trim($language['tag']) === $lang_tag) + if (trim($language['tag']) === $langTag) { - $lookup_lang_dirs[] = trim($folder . '/' . dirname($language), '/'); + $lookupLangDirs[] = trim($folder . '/' . dirname($language), '/'); } } } - $lookup_lang_dirs[] = ''; + $lookupLangDirs[] = ''; - $lookup_lang_dirs = array_unique($lookup_lang_dirs); + $lookupLangDirs = array_unique($lookupLangDirs); // Looking for language file in specified directories - foreach ($lookup_lang_dirs as $dir) + foreach ($lookupLangDirs as $dir) { - $lang_sys_file = - $lang_dir . '/' . + $langSysFile = + $langDir . '/' . ($dir === '' ? '' : $dir . '/') . - $lang_tag. '.' . $extension . '.sys.ini'; - if (is_file($lang_sys_file)) + $langTag. '.' . $extension . '.sys.ini'; + if (is_file($langSysFile)) { $loadLanguage = new ReflectionMethod($lang, 'loadLanguage'); $loadLanguage->setAccessible(true); - $loadLanguage->invoke($lang, $lang_sys_file, $extension); + $loadLanguage->invoke($lang, $langSysFile, $extension); break; } } // Get the real extension's name now that the language has been loaded - $extension_name = $lang->_((string) $xml->name); + $extensionName = $lang->_((string) $xml->name); - $info[] = JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_XML', $extension_name); + $info[] = JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_XML', $extensionName); $info[] = JText::sprintf('COM_JEDCHECKER_INFO_XML_VERSION_XML', (string) $xml->version); $info[] = JText::sprintf('COM_JEDCHECKER_INFO_XML_CREATIONDATE_XML', (string) $xml->creationDate); $this->report->addInfo($file, implode('
', $info)); // NM3 - Listing name contains “module” or “plugin” - if (preg_match('/module|plugin/i', $extension_name)) + if (preg_match('/module|plugin/i', $extensionName)) { - $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_MODULE_PLUGIN', $extension_name)); + $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_MODULE_PLUGIN', $extensionName)); } // The "template" is reserved keyword - if (stripos($extension_name, 'template') !== false) + if (stripos($extensionName, 'template') !== false) { - $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS', $extension_name)); + $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS', $extensionName)); } // NM5 - Version in name/title - if (preg_match('/(?:\bversion\b|\d\.\d)/i', $extension_name)) + if (preg_match('/(?:\bversion\b|\d\.\d)/i', $extensionName)) { - $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_VERSION', $extension_name)); + $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_VERSION', $extensionName)); } - if (stripos($extension_name, 'joomla') === 0) + if (stripos($extensionName, 'joomla') === 0) { // An extension name can't start with the word "Joomla" - $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA', $extension_name)); + $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA', $extensionName)); } - elseif (stripos($extension_name, 'joom') !== false) + elseif (stripos($extensionName, 'joom') !== false) { // Extensions that use "Joomla" or a derivative of Joomla in the extension name need to be licensed by OSM - $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE', $extension_name)); + $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE', $extensionName)); } - $url = (string)$xml->authorUrl; + $url = (string) $xml->authorUrl; + if (stripos($url, 'joom') !== false) { $domain = (strpos($url, '//') === false) ? $url : parse_url(trim($url), PHP_URL_HOST); @@ -273,26 +275,26 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule if ($type === 'component' && isset($xml->administration->menu)) { - $menu_name = $lang->_((string) $xml->administration->menu); + $menuName = $lang->_((string) $xml->administration->menu); // Do name the Component's admin menu the same as the extension name - if ($extension_name !== $menu_name) + if ($extensionName !== $menuName) { - $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_ADMIN_MENU', $menu_name, $extension_name)); + $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_ADMIN_MENU', $menuName, $extensionName)); } } if ($type === 'plugin') { // The name of your plugin must comply with the JED naming conventions - plugins in the form “{Type} - {Extension Name}”. - $parts = explode(' - ', $extension_name, 2); - $extension_name_group = isset($parts[1]) ? strtolower(preg_replace('/\s/', '', $parts[0])) : false; + $parts = explode(' - ', $extensionName, 2); + $extensionNameGroup = isset($parts[1]) ? strtolower(preg_replace('/\s/', '', $parts[0])) : false; $group = (string) $xml['group']; - if ($extension_name_group !== $group && $extension_name_group !== str_replace('-', '', $group) - && !(isset($this->pluginsGroupMap[$extension_name_group]) && $this->pluginsGroupMap[$extension_name_group] === $group) + if ($extensionNameGroup !== $group && $extensionNameGroup !== str_replace('-', '', $group) + && !(isset($this->pluginsGroupMap[$extensionNameGroup]) && $this->pluginsGroupMap[$extensionNameGroup] === $group) ) { - $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT', $extension_name)); + $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT', $extensionName)); } } From ef48e97221b8efb9cc8ffe38221c605cf81396a8 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sun, 4 Apr 2021 14:13:19 +0300 Subject: [PATCH 20/22] validate domain name in both authorUrl and packagerurl --- .../libraries/rules/xmlinfo.php | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index 1698465..a0bf7de 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -260,17 +260,11 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE', $extensionName)); } - $url = (string) $xml->authorUrl; + $this->validateDomain($file, (string) $xml->authorUrl); - if (stripos($url, 'joom') !== false) + if ($type === 'package' && (string) $xml->packagerurl !== (string) $xml->authorUrl) { - $domain = (strpos($url, '//') === false) ? $url : parse_url(trim($url), PHP_URL_HOST); - - if (stripos($domain, 'joom') !== false) - { - // Extensions that use "Joomla" or a derivative of Joomla in the domain name need to be licensed by OSM - $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE', $url, 'https://tm.joomla.org/approved-domains.html')); - } + $this->validateDomain($file, (string) $xml->packagerurl); } if ($type === 'component' && isset($xml->administration->menu)) @@ -301,4 +295,21 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule // All checks passed. Return true return true; } + + /** + * Check domain name contains "Joomla"/derivative + * + * @param string $file Current file name + * @param string $url URL to validate + */ + protected function validateDomain($file, $url) + { + $domain = (strpos($url, '//') === false) ? $url : parse_url(trim($url), PHP_URL_HOST); + + if (stripos($domain, 'joom') !== false) + { + // Extensions that use "Joomla" or a derivative of Joomla in the domain name need to be licensed by OSM + $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE', $url, 'https://tm.joomla.org/approved-domains.html')); + } + } } From 0c9c53038cd009580e89914eb6bdbf5cd10b69b3 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sun, 4 Apr 2021 15:08:43 +0300 Subject: [PATCH 21/22] fix Joomla codestyle --- .../components/com_jedchecker/libraries/rules/xmlinfo.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index a0bf7de..b0bc918 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -301,6 +301,8 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule * * @param string $file Current file name * @param string $url URL to validate + * + * @return void */ protected function validateDomain($file, $url) { From 942f5a6dc0381885b939083d309188e98284e5b7 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sun, 4 Apr 2021 16:06:01 +0300 Subject: [PATCH 22/22] Warning on outdated manifest format --- .../com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini | 1 + .../components/com_jedchecker/libraries/rules/xmlinfo.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini index 6742542..39047a4 100644 --- a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini +++ b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini @@ -40,6 +40,7 @@ COM_JEDCHECKER_LEAVE_A_REVIEW_JED="If you use this component, please post a rati COM_JEDCHECKER_INFO="Info" COM_JEDCHECKER_INFO_XML="Information about extension xml files" COM_JEDCHECKER_INFO_XML_DESC="The install name of your extension must match your listing name on JED. We scan the xml files and find the value of the name tag. Useful information for the "filename and install as" fields in the jed submission form" +COM_JEDCHECKER_INFO_XML_MANIFEST_OUTDATED="Manifest file uses outdated format. Use <extension> instead of <install> root tag name." COM_JEDCHECKER_INFO_XML_NAME_XML="The name tag in this file is: %s" COM_JEDCHECKER_INFO_XML_VERSION_XML="Version tag has the value: %s" COM_JEDCHECKER_INFO_XML_CREATIONDATE_XML="The creationDate tag has the value: %s" diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php index b0bc918..e470ae1 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php @@ -107,6 +107,11 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule // Check if this is an extension manifest // 1.5 uses 'install', 1.6+ uses 'extension' + if ($xml->getName() === 'install') + { + $this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_MANIFEST_OUTDATED')); + } + if ($xml->getName() !== 'extension') { return false;