From 74288b93d226f1ba9f491cb2b34d4176685f49c6 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Tue, 2 Feb 2021 18:58:29 +0300 Subject: [PATCH 01/40] Add XML manifest validator --- .../language/en-GB/en-GB.com_jedchecker.ini | 12 +- .../libraries/rules/xmlmanifest.php | 285 ++++++++++++++++++ .../rules/xmlmanifest_component.json | 129 ++++++++ .../libraries/rules/xmlmanifest_module.json | 117 +++++++ .../libraries/rules/xmlmanifest_plugin.json | 118 ++++++++ 5 files changed, 660 insertions(+), 1 deletion(-) create mode 100644 administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php create mode 100644 administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json create mode 100644 administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json create mode 100644 administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json 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..ab71533 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 @@ -77,4 +77,14 @@ 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" +COM_JEDCHECKER_MANIFEST="XML Manifest" +COM_JEDCHECKER_MANIFEST_DESC="Validation of extension's XML manifest file" +COM_JEDCHECKER_MANIFEST_UNKNOWN_TYPE="Unknown extension type: %s" +COM_JEDCHECKER_MANIFEST_TYPE_NOT_ACCEPTED="Extension type '%s' is not accepted by JED" +COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE="Node '%1$s' has unknown attribute '%2$s'" +COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN="Node '%s' has unknown child element" +COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED="Node '%1$s' doesn't contain required '%2$s' element" +COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND="Node '%1$s' contains multiple '%2$s' elements" +COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD="Node '%1$s' contains unknown '%2$s' element" +COM_JEDCHECKER_MANIFEST_MENU_UNUSED_ATTRIBUTE="Menu item attribute '%s' is not used with 'link' attribute" \ No newline at end of file diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php new file mode 100644 index 0000000..328605d --- /dev/null +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -0,0 +1,285 @@ + + * eaxs + * Denis Ryabov + * + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +defined('_JEXEC') or die('Restricted access'); + + +// Include the rule base class +require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php'; + + +/** + * class JedcheckerRulesXMLManifest + * + * This class validates all xml manifestes + * + * @since 1.0 + */ +class JedcheckerRulesXMLManifest extends JEDcheckerRule +{ + /** + * The formal ID of this rule. For example: SE1. + * + * @var string + */ + protected $id = 'MANIFEST'; + + /** + * The title or caption of this rule. + * + * @var string + */ + protected $title = 'COM_JEDCHECKER_MANIFEST'; + + /** + * The description of this rule. + * + * @var string + */ + protected $description = 'COM_JEDCHECKER_MANIFEST_DESC'; + + /** + * List of errors. + * + * @var string[] + */ + protected $errors; + + /** + * List of warnings. + * + * @var string[] + */ + protected $warnings; + + /** + * Rules for XML nodes + * ? - single, optional + * = - single, required, warning if missed + * ! - single, required, error if missed + * * - multiple, optional + * @var array + */ + protected $DTDNodeRules; + + /** + * Rules for attributes + * (list of allowed attributes) + * @var array + */ + protected $DTDAttrRules; + + protected $types = array( + 'component', 'file', 'language', 'library', + 'module', 'package', 'plugin', 'template' + ); + + /** + * Initiates the search and check + * + * @return void + */ + public function check() + { + // Find all XML files of the extension + $files = JFolder::files($this->basedir, '.xml$', true, true); + + // Iterate through all the xml files + foreach ($files as $file) + { + // Try to check the file + $this->find($file); + } + } + + /** + * Reads a file and validate XML manifest + * + * @param string $file - The path to the file + * + * @return boolean True if the manifest file was found, otherwise False. + */ + protected function find($file) + { + $xml = JFactory::getXml($file); + + // Failed to parse the xml file. + // Assume that this is not a extension manifest + if (!$xml) + { + return false; + } + + // Check if this is an extension manifest + if ($xml->getName() !== 'extension') + { + return false; + } + + // check extension type + $type = (string) $xml['type']; + if (!in_array($type, $this->types, true)) + { + $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_TYPE', $type)); + return true; + } + + // load DTD-like data for this extension type + $json_filename = __DIR__ . '/xmlmanifest_' . $type . '.json'; + if (!is_file($json_filename)) + { + $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_TYPE_NOT_ACCEPTED', $type)); + return true; + } + $data = json_decode(file_get_contents($json_filename), true); + $this->DTDNodeRules = $data['nodes']; + $this->DTDAttrRules = $data['attributes']; + + $this->errors = array(); + $this->warnings = array(); + + // validate manifest + $this->validateXml($xml, 'extension'); + + if (count($this->errors)) + { + $this->report->addError($file, implode('
', $this->errors)); + } + + if (count($this->warnings)) + { + $this->report->addWarning($file, implode('
', $this->warnings)); + } + + // All checks passed. Return true + return true; + } + + /** + * @param JXMLElement $node + * @param string $name + */ + protected function validateXml($node, $name) + { + // Check attributes + $DTDattributes = isset($this->DTDAttrRules[$name]) ? $this->DTDAttrRules[$name] : array(); + foreach ($node->attributes() as $attr) + { + $attr_name = (string)$attr->getName(); + if (!in_array($attr_name, $DTDattributes, true)) + { + $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, $attr_name); + } + } + + // Check children nodes + if (!isset($this->DTDNodeRules[$name])) + { + // No children + if ($node->count() > 0) + { + $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN', $name); + } + } else { + $DTDchildren = $this->DTDNodeRules[$name]; + + // 1) check required single elements + + foreach ($DTDchildren as $child => $mode) + { + $count = $node->$child->count(); + switch ($mode) + { + case '!': + $errors =& $this->errors; + break; + case '=': + $errors =& $this->warnings; + break; + default: + continue 2; + } + if ($count === 0) + { + $errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED', $name, $child); + } + elseif ($count > 1) + { + $errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child); + } + unset($errors); + } + + // 2) check unknown/multiple elements + + // collect unique child node names + $child_names = array(); + foreach ($node as $child) + { + $child_names[$child->getName()] = 1; + } + $child_names = array_keys($child_names); + + foreach ($child_names as $child) + { + if (!isset($DTDchildren[$child])) + { + $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD', $name, $child); + } + else + { + if ($DTDchildren[$child] === '?' && $node->$child->count() > 1) + { + $this->errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child); + } + } + } + } + + // Extra checks (if exist) + $method = 'validateXml' . $name; + if (method_exists($this, $method)) + { + $this->$method($node); + } + + // Recursion + foreach ($node as $child) + { + $child_name = $child->getName(); + if (isset($this->DTDNodeRules[$child_name])) { + $this->validateXml($child, $child_name); + } + } + } + + /** + * Extra check for menu nodes + * @param JXMLElement $node + */ + protected function validateXmlMenu($node) + { + if (isset($node['link'])) + { + $skip_attrs = array('act', 'controller', 'layout', 'sub', 'task', 'view'); + foreach ($node->attributes() as $attr) + { + $attr_name = $attr->getName(); + if (in_array($attr_name, $skip_attrs, true)) + { + $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MENU_UNUSED_ATTRIBUTE', $attr_name); + } + } + } + } +} diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json new file mode 100644 index 0000000..6a6d949 --- /dev/null +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json @@ -0,0 +1,129 @@ +{ + "nodes": { + "extension": { + "name": "!", + "element": "?", + "creationDate": "=", + "author": "=", + "authorEmail": "=", + "authorUrl": "=", + "copyright": "=", + "version": "!", + "description": "=", + "license": "!", + "scriptfile": "?", + "install": "?", + "update": "?", + "uninstall": "?", + "files": "?", + "languages": "?", + "media": "?", + "administration": "?", + "updateservers": "!", + "config": "?", + "dlid": "?" + }, + "administration": { + "menu": "=", + "submenu": "?", + "files": "=", + "languages": "=", + "media": "?" + }, + "files": { + "filename": "*", + "folder": "*" + }, + "languages": { + "language": "*" + }, + "media": { + "filename": "*", + "folder": "*" + }, + "submenu": { + "menu": "*" + }, + "install": { + "sql": "*" + }, + "update": { + "sql": "*", + "schemas": "*" + }, + "uninstall": { + "sql": "*" + }, + "sql": { + "file": "*" + }, + "schemas": { + "schemapath": "*" + }, + "updateservers": { + "server": "*" + }, + "config": { + "fields": "!" + }, + "fields": { + "fieldset": "+" + }, + "fieldset": { + "???": "*" + } + }, + "attributes": { + "extension": [ + "client", + "method", + "overwrite", + "type", + "version" + ], + "files": [ + "folder" + ], + "languages": [ + "folder" + ], + "language": [ + "client", + "tag" + ], + "media": [ + "destination", + "folder" + ], + "menu": [ + "act", + "controller", + "hidden", + "img", + "layout", + "link", + "sub", + "task", + "view" + ], + "file": [ + "charset", + "driver" + ], + "server": [ + "name", + "priority", + "type" + ], + "params": [ + "addParameterDir" + ], + "param": [ + "addParameterDir" + ], + "dlid": [ + "prefix", + "suffix" + ] + } +} \ No newline at end of file diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json new file mode 100644 index 0000000..8747f30 --- /dev/null +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json @@ -0,0 +1,117 @@ +{ + "nodes": { + "extension": { + "name": "!", + "element": "?", + "creationDate": "=", + "author": "=", + "authorEmail": "=", + "authorUrl": "=", + "copyright": "=", + "version": "!", + "description": "=", + "license": "!", + "scriptfile": "?", + "install": "?", + "update": "?", + "uninstall": "?", + "files": "?", + "languages": "?", + "media": "?", + "updateservers": "!", + "config": "?", + "dlid": "?" + }, + "files": { + "filename": "*", + "folder": "*" + }, + "languages": { + "language": "*" + }, + "media": { + "filename": "*", + "folder": "*" + }, + "install": { + "sql": "*" + }, + "update": { + "sql": "*", + "schemas": "*" + }, + "uninstall": { + "sql": "*" + }, + "sql": { + "file": "*" + }, + "updateservers": { + "server": "*" + }, + "config": { + "fields": "!" + }, + "fields": { + "fieldset": "+" + }, + "fieldset": { + "field": "+" + }, + "field": { + "option": "*" + } + }, + "attributes": { + "extension": [ + "client", + "method", + "overwrite", + "type", + "version" + ], + "files": [ + "folder" + ], + "filename": [ + "module" + ], + "languages": [ + "folder" + ], + "language": [ + "client", + "tag" + ], + "media": [ + "destination", + "folder" + ], + "file": [ + "charset", + "driver" + ], + "server": [ + "name", + "priority", + "type" + ], + "fields": [ + "addfieldpath", + "name" + ], + "fieldset": [ + "name" + ], + "field": [ + "default", + "description", + "label", + "name", + "type" + ], + "option": [ + "value" + ] + } +} \ No newline at end of file diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json new file mode 100644 index 0000000..45bd081 --- /dev/null +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json @@ -0,0 +1,118 @@ +{ + "nodes": { + "extension": { + "name": "!", + "element": "?", + "creationDate": "=", + "author": "=", + "authorEmail": "=", + "authorUrl": "=", + "copyright": "=", + "version": "!", + "description": "=", + "license": "!", + "scriptfile": "?", + "install": "?", + "update": "?", + "uninstall": "?", + "files": "?", + "languages": "?", + "media": "?", + "updateservers": "!", + "config": "?", + "dlid": "?" + }, + "files": { + "filename": "*", + "folder": "*" + }, + "languages": { + "language": "*" + }, + "media": { + "filename": "*", + "folder": "*" + }, + "install": { + "sql": "*" + }, + "update": { + "sql": "*", + "schemas": "*" + }, + "uninstall": { + "sql": "*" + }, + "sql": { + "file": "*" + }, + "updateservers": { + "server": "*" + }, + "config": { + "fields": "!" + }, + "fields": { + "fieldset": "+" + }, + "fieldset": { + "field": "+" + }, + "field": { + "option": "*" + } + }, + "attributes": { + "extension": [ + "client", + "group", + "method", + "overwrite", + "type", + "version" + ], + "files": [ + "folder" + ], + "filename": [ + "plugin" + ], + "languages": [ + "folder" + ], + "language": [ + "client", + "tag" + ], + "media": [ + "destination", + "folder" + ], + "file": [ + "charset", + "driver" + ], + "server": [ + "name", + "priority", + "type" + ], + "fields": [ + "addfieldpath", + "name" + ], + "fieldset": [ + "name" + ], + "field": [ + "default", + "description", + "label", + "name", + "type" + ], + "option": [ + "value" + ] + } +} \ No newline at end of file From 46ec8bd40aaf5c2f41bda3e098148f00be4a49a8 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Tue, 2 Feb 2021 19:10:59 +0300 Subject: [PATCH 02/40] update @since tag --- .../components/com_jedchecker/libraries/rules/xmlmanifest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index 328605d..7095a20 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -23,7 +23,7 @@ require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php'; * * This class validates all xml manifestes * - * @since 1.0 + * @since 2.3 */ class JedcheckerRulesXMLManifest extends JEDcheckerRule { From 329df9856253b160d2ab7200881c6427aec5d791 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sat, 13 Feb 2021 23:53:09 +0300 Subject: [PATCH 03/40] Joomla!4 compatibility --- .../com_jedchecker/libraries/rules/xmlmanifest.php | 2 +- .../libraries/rules/xmlmanifest_component.json | 6 +++++- .../com_jedchecker/libraries/rules/xmlmanifest_module.json | 6 +++++- .../com_jedchecker/libraries/rules/xmlmanifest_plugin.json | 6 +++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index 7095a20..506f7f9 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -111,7 +111,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule */ protected function find($file) { - $xml = JFactory::getXml($file); + $xml = simplexml_load_file($file); // Failed to parse the xml file. // Assume that this is not a extension manifest diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json index 6a6d949..c155b1e 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json @@ -21,7 +21,8 @@ "administration": "?", "updateservers": "!", "config": "?", - "dlid": "?" + "dlid": "?", + "namespace": "?" }, "administration": { "menu": "=", @@ -115,6 +116,9 @@ "priority", "type" ], + "namespace": [ + "path" + ], "params": [ "addParameterDir" ], diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json index 8747f30..8792f34 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json @@ -20,7 +20,8 @@ "media": "?", "updateservers": "!", "config": "?", - "dlid": "?" + "dlid": "?", + "namespace": "?" }, "files": { "filename": "*", @@ -96,6 +97,9 @@ "priority", "type" ], + "namespace": [ + "path" + ], "fields": [ "addfieldpath", "name" diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json index 45bd081..8f75832 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json @@ -20,7 +20,8 @@ "media": "?", "updateservers": "!", "config": "?", - "dlid": "?" + "dlid": "?", + "namespace": "?" }, "files": { "filename": "*", @@ -97,6 +98,9 @@ "priority", "type" ], + "namespace": [ + "path" + ], "fields": [ "addfieldpath", "name" From 331a9e162f00ec1c4898e763810144766900ccf7 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sat, 13 Feb 2021 23:53:26 +0300 Subject: [PATCH 04/40] support for "package" type --- .../libraries/rules/xmlmanifest_package.json | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 administrator/components/com_jedchecker/libraries/rules/xmlmanifest_package.json diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_package.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_package.json new file mode 100644 index 0000000..393aaeb --- /dev/null +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_package.json @@ -0,0 +1,64 @@ +{ + "nodes": { + "extension": { + "name": "!", + "packagename": "!", + "creationDate": "=", + "author": "=", + "authorEmail": "=", + "authorUrl": "=", + "copyright": "=", + "version": "!", + "description": "=", + "license": "!", + "scriptfile": "?", + "update": "?", + "files": "?", + "languages": "?", + "updateservers": "!", + "dlid": "?", + "packager": "?", + "packagerurl": "?", + "blockChildUninstall": "?" + }, + "files": { + "file": "*", + "folder": "*" + }, + "languages": { + "language": "*" + }, + "updateservers": { + "server": "*" + } + }, + "attributes": { + "extension": [ + "method", + "overwrite", + "type", + "version" + ], + "files": [ + "folder" + ], + "file": [ + "client", + "group", + "id", + "type" + ], + "languages": [ + "folder" + ], + "language": [ + "client", + "tag" + ], + "server": [ + "name", + "priority", + "type" + ] + } +} \ No newline at end of file From 4f899fb39bb5098030cbe04f43d2458ac9ca5ad0 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sat, 13 Feb 2021 23:53:36 +0300 Subject: [PATCH 05/40] fix regex --- .../components/com_jedchecker/libraries/rules/xmlmanifest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index 506f7f9..2802fd0 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -92,7 +92,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule public function check() { // Find all XML files of the extension - $files = JFolder::files($this->basedir, '.xml$', true, true); + $files = JFolder::files($this->basedir, '\.xml$', true, true); // Iterate through all the xml files foreach ($files as $file) From 4850ef0d43a19ca64121c1f7e46de1593f4f6e8d Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sun, 14 Feb 2021 01:18:25 +0300 Subject: [PATCH 06/40] remove check of config section from component manifest --- .../libraries/rules/xmlmanifest_component.json | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json index c155b1e..4733143 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json @@ -64,15 +64,6 @@ "updateservers": { "server": "*" }, - "config": { - "fields": "!" - }, - "fields": { - "fieldset": "+" - }, - "fieldset": { - "???": "*" - } }, "attributes": { "extension": [ @@ -119,12 +110,6 @@ "namespace": [ "path" ], - "params": [ - "addParameterDir" - ], - "param": [ - "addParameterDir" - ], "dlid": [ "prefix", "suffix" From 75d1f5f8710989d37442660af501e21601d4816d Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sun, 14 Feb 2021 01:19:04 +0300 Subject: [PATCH 07/40] add more field attributes and fieldset params --- .../libraries/rules/xmlmanifest_module.json | 14 +++++++++++++- .../libraries/rules/xmlmanifest_plugin.json | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json index 8792f34..e387a2f 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json @@ -105,14 +105,26 @@ "name" ], "fieldset": [ + "description", + "label", "name" ], "field": [ + "class", + "cols", "default", "description", + "filter", + "id", "label", + "maxLength", "name", - "type" + "required", + "rows", + "size", + "step", + "type", + "validate" ], "option": [ "value" diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json index 8f75832..3eaa7f3 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json @@ -106,14 +106,26 @@ "name" ], "fieldset": [ + "description", + "label", "name" ], "field": [ + "class", + "cols", "default", "description", + "filter", + "id", "label", + "maxLength", "name", - "type" + "required", + "rows", + "size", + "step", + "type", + "validate" ], "option": [ "value" From 8b0898713d01b5d01c3d1b9d6dc8758fdb8d680b Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 18 Feb 2021 15:16:51 +0300 Subject: [PATCH 08/40] fix json --- .../com_jedchecker/libraries/rules/xmlmanifest_component.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json index 4733143..1802074 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json @@ -63,7 +63,7 @@ }, "updateservers": { "server": "*" - }, + } }, "attributes": { "extension": [ From d508bbad6b1023ca38a29bc30c615cbe19b7e200 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 18 Feb 2021 15:17:13 +0300 Subject: [PATCH 09/40] add addfieldpath attribute to all form fields --- .../com_jedchecker/libraries/rules/xmlmanifest_module.json | 5 +++++ .../com_jedchecker/libraries/rules/xmlmanifest_plugin.json | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json index e387a2f..87615ce 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json @@ -100,16 +100,21 @@ "namespace": [ "path" ], + "config": [ + "addfieldpath" + ], "fields": [ "addfieldpath", "name" ], "fieldset": [ + "addfieldpath", "description", "label", "name" ], "field": [ + "addfieldpath", "class", "cols", "default", diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json index 3eaa7f3..4eb09ef 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json @@ -101,16 +101,21 @@ "namespace": [ "path" ], + "config": [ + "addfieldpath" + ], "fields": [ "addfieldpath", "name" ], "fieldset": [ + "addfieldpath", "description", "label", "name" ], "field": [ + "addfieldpath", "class", "cols", "default", From 77ffde4f6ccef7499d03f7ec3a99735488dfb82f Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 11 Mar 2021 01:08:23 +0300 Subject: [PATCH 10/40] correct authors list for new rule --- .../components/com_jedchecker/libraries/rules/xmlmanifest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index 2802fd0..27b97ca 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -4,9 +4,7 @@ * * @copyright Copyright (C) 2017 - 2021 Open Source Matters, Inc. All rights reserved. * Copyright (C) 2008 - 2016 compojoom.com . All rights reserved. - * @author Daniel Dimitrov - * eaxs - * Denis Ryabov + * @author Denis Ryabov * * @license GNU General Public License version 2 or later; see LICENSE.txt */ From 62a887092cc31c0c48d40b144a066dc780796ebb Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 00:27:50 +0300 Subject: [PATCH 11/40] move dtd files to a separate directory --- .../components/com_jedchecker/libraries/rules/xmlmanifest.php | 2 +- .../dtd_component.json} | 0 .../{xmlmanifest_module.json => xmlmanifest/dtd_module.json} | 0 .../{xmlmanifest_package.json => xmlmanifest/dtd_package.json} | 0 .../{xmlmanifest_plugin.json => xmlmanifest/dtd_plugin.json} | 0 5 files changed, 1 insertion(+), 1 deletion(-) rename administrator/components/com_jedchecker/libraries/rules/{xmlmanifest_component.json => xmlmanifest/dtd_component.json} (100%) rename administrator/components/com_jedchecker/libraries/rules/{xmlmanifest_module.json => xmlmanifest/dtd_module.json} (100%) rename administrator/components/com_jedchecker/libraries/rules/{xmlmanifest_package.json => xmlmanifest/dtd_package.json} (100%) rename administrator/components/com_jedchecker/libraries/rules/{xmlmanifest_plugin.json => xmlmanifest/dtd_plugin.json} (100%) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index 27b97ca..7755ba4 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -133,7 +133,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule } // load DTD-like data for this extension type - $json_filename = __DIR__ . '/xmlmanifest_' . $type . '.json'; + $json_filename = __DIR__ . '/xmlmanifest/dtd_' . $type . '.json'; if (!is_file($json_filename)) { $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_TYPE_NOT_ACCEPTED', $type)); diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json similarity index 100% rename from administrator/components/com_jedchecker/libraries/rules/xmlmanifest_component.json rename to administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json similarity index 100% rename from administrator/components/com_jedchecker/libraries/rules/xmlmanifest_module.json rename to administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_package.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json similarity index 100% rename from administrator/components/com_jedchecker/libraries/rules/xmlmanifest_package.json rename to administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json similarity index 100% rename from administrator/components/com_jedchecker/libraries/rules/xmlmanifest_plugin.json rename to administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json From f7353bf312d386a587982f5862b37e767b1d04ec Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 00:32:28 +0300 Subject: [PATCH 12/40] add support of any attribute (by using '*' as value) --- .../com_jedchecker/libraries/rules/xmlmanifest.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index 7755ba4..5ca2c72 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -171,12 +171,17 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule { // Check attributes $DTDattributes = isset($this->DTDAttrRules[$name]) ? $this->DTDAttrRules[$name] : array(); - foreach ($node->attributes() as $attr) + + if (isset($DTDattributes[0]) && $DTDattributes[0] !== '*') { - $attr_name = (string)$attr->getName(); - if (!in_array($attr_name, $DTDattributes, true)) + foreach ($node->attributes() as $attr) { - $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, $attr_name); + $attr_name = (string)$attr->getName(); + + if (!in_array($attr_name, $DTDattributes, true)) + { + $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, $attr_name); + } } } From 79caa44fca1c2c0fc1576115ef7709ae46ef9d27 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 00:33:37 +0300 Subject: [PATCH 13/40] add support of any children (by using '*' as key) --- .../components/com_jedchecker/libraries/rules/xmlmanifest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index 5ca2c72..f52366a 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -193,7 +193,9 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule { $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN', $name); } - } else { + } + elseif (!isset($this->DTDNodeRules[$name]['*'])) + { $DTDchildren = $this->DTDNodeRules[$name]; // 1) check required single elements From ab751af635b2a215504519f3919c090fbf01bb3a Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 00:37:02 +0300 Subject: [PATCH 14/40] remove error for missed license and updateservers tags (as they are processed by other rules) --- .../libraries/rules/xmlmanifest/dtd_component.json | 4 ++-- .../libraries/rules/xmlmanifest/dtd_module.json | 4 ++-- .../libraries/rules/xmlmanifest/dtd_package.json | 4 ++-- .../libraries/rules/xmlmanifest/dtd_plugin.json | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json index 1802074..735d2a9 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json @@ -10,7 +10,7 @@ "copyright": "=", "version": "!", "description": "=", - "license": "!", + "license": "?", "scriptfile": "?", "install": "?", "update": "?", @@ -19,7 +19,7 @@ "languages": "?", "media": "?", "administration": "?", - "updateservers": "!", + "updateservers": "?", "config": "?", "dlid": "?", "namespace": "?" diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json index 87615ce..e4f8daa 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json @@ -10,7 +10,7 @@ "copyright": "=", "version": "!", "description": "=", - "license": "!", + "license": "?", "scriptfile": "?", "install": "?", "update": "?", @@ -18,7 +18,7 @@ "files": "?", "languages": "?", "media": "?", - "updateservers": "!", + "updateservers": "?", "config": "?", "dlid": "?", "namespace": "?" diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json index 393aaeb..b2b5074 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json @@ -10,12 +10,12 @@ "copyright": "=", "version": "!", "description": "=", - "license": "!", + "license": "?", "scriptfile": "?", "update": "?", "files": "?", "languages": "?", - "updateservers": "!", + "updateservers": "?", "dlid": "?", "packager": "?", "packagerurl": "?", diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json index 4eb09ef..e1ff6a8 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json @@ -10,7 +10,7 @@ "copyright": "=", "version": "!", "description": "=", - "license": "!", + "license": "?", "scriptfile": "?", "install": "?", "update": "?", @@ -18,7 +18,7 @@ "files": "?", "languages": "?", "media": "?", - "updateservers": "!", + "updateservers": "?", "config": "?", "dlid": "?", "namespace": "?" From ffd09958305aa0481257aec5d0c4e29153b493fe Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 00:38:07 +0300 Subject: [PATCH 15/40] fix dtd for config section in modules and plugins --- .../rules/xmlmanifest/dtd_module.json | 39 +++++++++---------- .../rules/xmlmanifest/dtd_plugin.json | 39 +++++++++---------- 2 files changed, 36 insertions(+), 42 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json index e4f8daa..1694b13 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json @@ -60,7 +60,7 @@ "field": "+" }, "field": { - "option": "*" + "*": "*" } }, "attributes": { @@ -101,38 +101,35 @@ "path" ], "config": [ - "addfieldpath" + "addfieldpath", + "addfieldprefix", + "addformpath", + "addformprefix", + "addrulepath", + "addruleprefix" ], "fields": [ "addfieldpath", + "addfieldprefix", + "addformpath", + "addformprefix", + "addrulepath", + "addruleprefix", "name" ], "fieldset": [ "addfieldpath", + "addfieldprefix", + "addformpath", + "addformprefix", + "addrulepath", + "addruleprefix", "description", "label", "name" ], "field": [ - "addfieldpath", - "class", - "cols", - "default", - "description", - "filter", - "id", - "label", - "maxLength", - "name", - "required", - "rows", - "size", - "step", - "type", - "validate" - ], - "option": [ - "value" + "*" ] } } \ No newline at end of file diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json index e1ff6a8..b459b2c 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json @@ -60,7 +60,7 @@ "field": "+" }, "field": { - "option": "*" + "*": "*" } }, "attributes": { @@ -102,38 +102,35 @@ "path" ], "config": [ - "addfieldpath" + "addfieldpath", + "addfieldprefix", + "addformpath", + "addformprefix", + "addrulepath", + "addruleprefix" ], "fields": [ "addfieldpath", + "addfieldprefix", + "addformpath", + "addformprefix", + "addrulepath", + "addruleprefix", "name" ], "fieldset": [ "addfieldpath", + "addfieldprefix", + "addformpath", + "addformprefix", + "addrulepath", + "addruleprefix", "description", "label", "name" ], "field": [ - "addfieldpath", - "class", - "cols", - "default", - "description", - "filter", - "id", - "label", - "maxLength", - "name", - "required", - "rows", - "size", - "step", - "type", - "validate" - ], - "option": [ - "value" + "*" ] } } \ No newline at end of file From b74a082198495e6d3fbe10f1533f86480d62dd40 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 00:38:42 +0300 Subject: [PATCH 16/40] support both file and filename names for files children in package manifest --- .../libraries/rules/xmlmanifest/dtd_package.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json index b2b5074..703fb88 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json @@ -23,6 +23,7 @@ }, "files": { "file": "*", + "filename": "*", "folder": "*" }, "languages": { @@ -48,6 +49,12 @@ "id", "type" ], + "filename": [ + "client", + "group", + "id", + "type" + ], "languages": [ "folder" ], From a73780e5245ad5f0fd73a41bb8d9ec77b9eb4197 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 00:39:10 +0300 Subject: [PATCH 17/40] don't require menu and languages sections in components --- .../libraries/rules/xmlmanifest/dtd_component.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json index 735d2a9..96f9d61 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json @@ -25,10 +25,10 @@ "namespace": "?" }, "administration": { - "menu": "=", + "menu": "?", "submenu": "?", "files": "=", - "languages": "=", + "languages": "?", "media": "?" }, "files": { From db4d6ea7f2140f347aa6d6009725f724c75e9fd6 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 11 Mar 2021 01:12:57 +0300 Subject: [PATCH 18/40] change title to plural --- .../com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini | 4 ++-- 1 file 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 ab71533..16bdb1c 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 @@ -78,7 +78,7 @@ COM_JEDCHECKER_INFO_XML_UPDATE_SERVER_LINK="The Update Server link in this XML f 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" -COM_JEDCHECKER_MANIFEST="XML Manifest" +COM_JEDCHECKER_MANIFEST="XML Manifests" COM_JEDCHECKER_MANIFEST_DESC="Validation of extension's XML manifest file" COM_JEDCHECKER_MANIFEST_UNKNOWN_TYPE="Unknown extension type: %s" COM_JEDCHECKER_MANIFEST_TYPE_NOT_ACCEPTED="Extension type '%s' is not accepted by JED" @@ -87,4 +87,4 @@ COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN="Node '%s' has unknown child element" COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED="Node '%1$s' doesn't contain required '%2$s' element" COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND="Node '%1$s' contains multiple '%2$s' elements" COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD="Node '%1$s' contains unknown '%2$s' element" -COM_JEDCHECKER_MANIFEST_MENU_UNUSED_ATTRIBUTE="Menu item attribute '%s' is not used with 'link' attribute" \ No newline at end of file +COM_JEDCHECKER_MANIFEST_MENU_UNUSED_ATTRIBUTE="Menu item attribute '%s' is not used with 'link' attribute" From 9855b35debcafbc32ee2c769d2a3da131423147e Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 02:27:08 +0300 Subject: [PATCH 19/40] use angle brackets for nodes names --- .../language/en-GB/en-GB.com_jedchecker.ini | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 16bdb1c..e5922f0 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 @@ -82,9 +82,9 @@ COM_JEDCHECKER_MANIFEST="XML Manifests" COM_JEDCHECKER_MANIFEST_DESC="Validation of extension's XML manifest file" COM_JEDCHECKER_MANIFEST_UNKNOWN_TYPE="Unknown extension type: %s" COM_JEDCHECKER_MANIFEST_TYPE_NOT_ACCEPTED="Extension type '%s' is not accepted by JED" -COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE="Node '%1$s' has unknown attribute '%2$s'" -COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN="Node '%s' has unknown child element" -COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED="Node '%1$s' doesn't contain required '%2$s' element" -COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND="Node '%1$s' contains multiple '%2$s' elements" -COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD="Node '%1$s' contains unknown '%2$s' element" +COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE="Node <%1$s> has unknown attribute '%2$s'" +COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN="Node <%s> has unknown child element" +COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED="Node <%1$s> doesn't contain required <%2$s> element" +COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND="Node <%1$s> contains multiple <%2$s> elements" +COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD="Node <%1$s> contains unknown <%2$s> element" COM_JEDCHECKER_MANIFEST_MENU_UNUSED_ATTRIBUTE="Menu item attribute '%s' is not used with 'link' attribute" From 825208b28c93e4d312d066c7c0343e393de424c7 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 02:27:49 +0300 Subject: [PATCH 20/40] add DTD json for language packages --- .../rules/xmlmanifest/dtd_language.json | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json new file mode 100644 index 0000000..e6002de --- /dev/null +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json @@ -0,0 +1,60 @@ +{ + "nodes": { + "extension": { + "name": "!", + "tag": "!", + "creationDate": "=", + "author": "=", + "authorEmail": "=", + "authorUrl": "=", + "copyright": "=", + "version": "!", + "description": "=", + "license": "?", + "files": "!", + "media": "?", + "fonts": "?", + "update": "?", + "updateservers": "?" + }, + "files": { + "filename": "*", + "folder": "*" + }, + "media": { + "filename": "*", + "folder": "*" + }, + "fonts": { + "filename": "*", + "folder": "*" + }, + "updateservers": { + "server": "*" + } + }, + "attributes": { + "extension": [ + "client", + "method", + "overwrite", + "type", + "version" + ], + "files": [ + "folder" + ], + "media": [ + "destination", + "folder" + ], + "fonts": [ + "folder" + ], + "server": [ + "name", + "priority", + "type" + ] + } +} \ No newline at end of file From d353c8b2f85ede8dd45fe7c6d179f1dc95630f9c Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 11 Mar 2021 01:15:13 +0300 Subject: [PATCH 21/40] commenting the code --- .../components/com_jedchecker/libraries/rules/xmlmanifest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index f52366a..855228f 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -180,6 +180,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule if (!in_array($attr_name, $DTDattributes, true)) { + // The node has unknown attribute $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, $attr_name); } } @@ -276,6 +277,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule { if (isset($node['link'])) { + // The "link" attribute overrides any other link-related attributes (warn if they present) $skip_attrs = array('act', 'controller', 'layout', 'sub', 'task', 'view'); foreach ($node->attributes() as $attr) { From 321221a49524b36149aa424e586574ab38e437fe Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 11 Mar 2021 13:39:11 +0300 Subject: [PATCH 22/40] remove `@author` tag --- .../components/com_jedchecker/libraries/rules/xmlmanifest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index 855228f..be3a420 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -4,7 +4,6 @@ * * @copyright Copyright (C) 2017 - 2021 Open Source Matters, Inc. All rights reserved. * Copyright (C) 2008 - 2016 compojoom.com . All rights reserved. - * @author Denis Ryabov * * @license GNU General Public License version 2 or later; see LICENSE.txt */ From 01c5c5e550374cca714a04eb5b1b6fae7a5e5f80 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 11 Mar 2021 15:56:27 +0300 Subject: [PATCH 23/40] fix copyright --- .../components/com_jedchecker/libraries/rules/xmlmanifest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index be3a420..682a3af 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -2,8 +2,7 @@ /** * @package Joomla.JEDChecker * - * @copyright Copyright (C) 2017 - 2021 Open Source Matters, Inc. All rights reserved. - * Copyright (C) 2008 - 2016 compojoom.com . All rights reserved. + * @copyright Copyright (C) 2021 Open Source Matters, Inc. All rights reserved. * * @license GNU General Public License version 2 or later; see LICENSE.txt */ From ae251b5d5b4b7a0cb4f57054385b7acfa3955912 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sun, 4 Apr 2021 13:59:50 +0300 Subject: [PATCH 24/40] Joomla! code style fixes --- .../libraries/rules/xmlmanifest.php | 72 ++++++++++++------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index 682a3af..c0559ba 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -17,7 +17,7 @@ require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php'; /** * class JedcheckerRulesXMLManifest * - * This class validates all xml manifestes + * This class validates all XML manifests * * @since 2.3 */ @@ -75,9 +75,14 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule */ protected $DTDAttrRules; + /** + * List of extension types + * + * @var string[] + */ protected $types = array( - 'component', 'file', 'language', 'library', - 'module', 'package', 'plugin', 'template' + 'component', 'file', 'language', 'library', + 'module', 'package', 'plugin', 'template' ); /** @@ -122,21 +127,26 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule return false; } - // check extension type + // Check extension type $type = (string) $xml['type']; + if (!in_array($type, $this->types, true)) { $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_TYPE', $type)); + return true; } - // load DTD-like data for this extension type + // Load DTD-like data for this extension type $json_filename = __DIR__ . '/xmlmanifest/dtd_' . $type . '.json'; + if (!is_file($json_filename)) { $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_TYPE_NOT_ACCEPTED', $type)); + return true; } + $data = json_decode(file_get_contents($json_filename), true); $this->DTDNodeRules = $data['nodes']; $this->DTDAttrRules = $data['attributes']; @@ -144,7 +154,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule $this->errors = array(); $this->warnings = array(); - // validate manifest + // Validate manifest $this->validateXml($xml, 'extension'); if (count($this->errors)) @@ -162,8 +172,10 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule } /** - * @param JXMLElement $node - * @param string $name + * @param SimpleXMLElement $node XML node object + * @param string $name XML node name + * + * @return void */ protected function validateXml($node, $name) { @@ -174,12 +186,12 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule { foreach ($node->attributes() as $attr) { - $attr_name = (string)$attr->getName(); + $attrName = (string)$attr->getName(); - if (!in_array($attr_name, $DTDattributes, true)) + if (!in_array($attrName, $DTDattributes, true)) { // The node has unknown attribute - $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, $attr_name); + $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, $attrName); } } } @@ -202,6 +214,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule foreach ($DTDchildren as $child => $mode) { $count = $node->$child->count(); + switch ($mode) { case '!': @@ -213,6 +226,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule default: continue 2; } + if ($count === 0) { $errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED', $name, $child); @@ -221,20 +235,22 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule { $errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child); } + unset($errors); } // 2) check unknown/multiple elements - // collect unique child node names - $child_names = array(); + // Collect unique child node names + $childNames = array(); + foreach ($node as $child) { - $child_names[$child->getName()] = 1; + $childNames[$child->getName()] = 1; } - $child_names = array_keys($child_names); + $childNames = array_keys($childNames); - foreach ($child_names as $child) + foreach ($childNames as $child) { if (!isset($DTDchildren[$child])) { @@ -252,6 +268,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule // Extra checks (if exist) $method = 'validateXml' . $name; + if (method_exists($this, $method)) { $this->$method($node); @@ -260,29 +277,34 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule // Recursion foreach ($node as $child) { - $child_name = $child->getName(); - if (isset($this->DTDNodeRules[$child_name])) { - $this->validateXml($child, $child_name); + $childName = $child->getName(); + + if (isset($this->DTDNodeRules[$childName])) + { + $this->validateXml($child, $childName); } } } /** - * Extra check for menu nodes - * @param JXMLElement $node + * @param SimpleXMLElement $node XML node + * + * @return void */ protected function validateXmlMenu($node) { if (isset($node['link'])) { // The "link" attribute overrides any other link-related attributes (warn if they present) - $skip_attrs = array('act', 'controller', 'layout', 'sub', 'task', 'view'); + $skipAttrs = array('act', 'controller', 'layout', 'sub', 'task', 'view'); + foreach ($node->attributes() as $attr) { - $attr_name = $attr->getName(); - if (in_array($attr_name, $skip_attrs, true)) + $attrName = $attr->getName(); + + if (in_array($attrName, $skipAttrs, true)) { - $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MENU_UNUSED_ATTRIBUTE', $attr_name); + $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MENU_UNUSED_ATTRIBUTE', $attrName); } } } From 49b383514e180248913f2c75a173d97c5d3e238d Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sun, 4 Apr 2021 14:19:14 +0300 Subject: [PATCH 25/40] change unknown children and attribute to just an info-level message --- .../libraries/rules/xmlmanifest.php | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index c0559ba..db2f211 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -58,6 +58,13 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule */ protected $warnings; + /** + * List of infos. + * + * @var string[] + */ + protected $infos; + /** * Rules for XML nodes * ? - single, optional @@ -153,6 +160,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule $this->errors = array(); $this->warnings = array(); + $this->infos = array(); // Validate manifest $this->validateXml($xml, 'extension'); @@ -167,6 +175,11 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule $this->report->addWarning($file, implode('
', $this->warnings)); } + if (count($this->infos)) + { + $this->report->addInfo($file, implode('
', $this->infos)); + } + // All checks passed. Return true return true; } @@ -186,12 +199,12 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule { foreach ($node->attributes() as $attr) { - $attrName = (string)$attr->getName(); + $attrName = (string) $attr->getName(); if (!in_array($attrName, $DTDattributes, true)) { // The node has unknown attribute - $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, $attrName); + $this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, $attrName); } } } @@ -202,7 +215,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule // No children if ($node->count() > 0) { - $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN', $name); + $this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN', $name); } } elseif (!isset($this->DTDNodeRules[$name]['*'])) @@ -248,13 +261,14 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule { $childNames[$child->getName()] = 1; } + $childNames = array_keys($childNames); foreach ($childNames as $child) { if (!isset($DTDchildren[$child])) { - $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD', $name, $child); + $this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD', $name, $child); } else { @@ -287,6 +301,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule } /** + * Extra check for menu nodes * @param SimpleXMLElement $node XML node * * @return void From 4d658b082ceb636a9c5aadfa636fd602129f7858 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 14:57:11 +0300 Subject: [PATCH 26/40] new inspection: empty element --- .../language/en-GB/en-GB.com_jedchecker.ini | 1 + .../com_jedchecker/libraries/rules/xmlmanifest.php | 9 +++++++++ 2 files changed, 10 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 e5922f0..a5cd2d1 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 @@ -87,4 +87,5 @@ COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN="Node <%s> has unknown child elem COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED="Node <%1$s> doesn't contain required <%2$s> element" COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND="Node <%1$s> contains multiple <%2$s> elements" COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD="Node <%1$s> contains unknown <%2$s> element" +COM_JEDCHECKER_MANIFEST_EMPTY_CHILD="Found empty <%s> element" COM_JEDCHECKER_MANIFEST_MENU_UNUSED_ATTRIBUTE="Menu item attribute '%s' is not used with 'link' attribute" diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index db2f211..b7a39c2 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -278,6 +278,15 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule } } } + + // 3) check empty elements + foreach ($node as $child) + { + if ($child->count() === 0 && (string) $child === '') + { + $this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_EMPTY_CHILD', $child->getName()); + } + } } // Extra checks (if exist) From d228600cf776405cd74c185952810c9c10926389 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 24 Feb 2021 15:59:20 +0300 Subject: [PATCH 27/40] don't warn on empty child with attributes (e.g. field nodes) --- .../components/com_jedchecker/libraries/rules/xmlmanifest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index b7a39c2..b433331 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -282,7 +282,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule // 3) check empty elements foreach ($node as $child) { - if ($child->count() === 0 && (string) $child === '') + if ($child->count() === 0 && $child->attributes()->count() === 0 && (string) $child === '') { $this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_EMPTY_CHILD', $child->getName()); } From ed7eb05279ea0f8a954ae469f3c656206448be15 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 25 Feb 2021 14:43:17 +0300 Subject: [PATCH 28/40] support optional url tag in packages --- .../com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json index 703fb88..d46ca2e 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json @@ -17,6 +17,7 @@ "languages": "?", "updateservers": "?", "dlid": "?", + "url": "?", "packager": "?", "packagerurl": "?", "blockChildUninstall": "?" From 9b36852506751a14a874981d2954c72ff630ee6d Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sat, 27 Feb 2021 02:11:55 +0300 Subject: [PATCH 29/40] dtd-json files for file, library, and template manifests --- .../libraries/rules/xmlmanifest/dtd_file.json | 85 +++++++++++++ .../rules/xmlmanifest/dtd_library.json | 91 ++++++++++++++ .../rules/xmlmanifest/dtd_template.json | 115 ++++++++++++++++++ 3 files changed, 291 insertions(+) create mode 100644 administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_file.json create mode 100644 administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json create mode 100644 administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_template.json diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_file.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_file.json new file mode 100644 index 0000000..86ba299 --- /dev/null +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_file.json @@ -0,0 +1,85 @@ +{ + "nodes": { + "extension": { + "name": "!", + "creationDate": "=", + "author": "=", + "authorEmail": "=", + "authorUrl": "=", + "copyright": "=", + "version": "!", + "description": "=", + "license": "?", + "scriptfile": "?", + "install": "?", + "update": "?", + "uninstall": "?", + "fileset": "!", + "languages": "?", + "updateservers": "?", + "dlid": "?" + }, + "fileset": { + "files": "=" + }, + "files": { + "filename": "*", + "folder": "*" + }, + "languages": { + "language": "*" + }, + "install": { + "sql": "*" + }, + "update": { + "sql": "*", + "schemas": "*" + }, + "uninstall": { + "sql": "*" + }, + "sql": { + "file": "*" + }, + "schemas": { + "schemapath": "*" + }, + "updateservers": { + "server": "*" + } + }, + "attributes": { + "extension": [ + "client", + "method", + "overwrite", + "type", + "version" + ], + "files": [ + "folder", + "target" + ], + "languages": [ + "folder" + ], + "language": [ + "client", + "tag" + ], + "file": [ + "charset", + "driver" + ], + "server": [ + "name", + "priority", + "type" + ], + "dlid": [ + "prefix", + "suffix" + ] + } +} \ No newline at end of file diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json new file mode 100644 index 0000000..1ab2d25 --- /dev/null +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json @@ -0,0 +1,91 @@ +{ + "nodes": { + "extension": { + "name": "!", + "libraryname": "!", + "creationDate": "=", + "author": "=", + "authorEmail": "=", + "authorUrl": "=", + "copyright": "=", + "version": "!", + "description": "=", + "license": "?", + "scriptfile": "?", + "install": "?", + "update": "?", + "uninstall": "?", + "files": "?", + "languages": "?", + "media": "?", + "updateservers": "?", + "dlid": "?" + }, + "files": { + "filename": "*", + "folder": "*" + }, + "languages": { + "language": "*" + }, + "media": { + "filename": "*", + "folder": "*" + }, + "install": { + "sql": "*" + }, + "update": { + "sql": "*", + "schemas": "*" + }, + "uninstall": { + "sql": "*" + }, + "sql": { + "file": "*" + }, + "schemas": { + "schemapath": "*" + }, + "updateservers": { + "server": "*" + } + }, + "attributes": { + "extension": [ + "client", + "method", + "overwrite", + "type", + "version" + ], + "files": [ + "folder" + ], + "languages": [ + "folder" + ], + "language": [ + "client", + "tag" + ], + "media": [ + "destination", + "folder" + ], + "file": [ + "charset", + "driver" + ], + "server": [ + "name", + "priority", + "type" + ], + "dlid": [ + "prefix", + "suffix" + ] + } +} \ No newline at end of file diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_template.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_template.json new file mode 100644 index 0000000..efe3f9e --- /dev/null +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_template.json @@ -0,0 +1,115 @@ +{ + "nodes": { + "extension": { + "name": "!", + "element": "?", + "creationDate": "=", + "author": "=", + "authorEmail": "=", + "authorUrl": "=", + "copyright": "=", + "version": "!", + "description": "=", + "license": "?", + "scriptfile": "?", + "install": "?", + "update": "?", + "uninstall": "?", + "files": "?", + "images": "?", + "css": "?", + "languages": "?", + "media": "?", + "positions": "!", + "updateservers": "?", + "dlid": "?", + "config": "?" + }, + "positions": { + "position": "*" + }, + "files": { + "filename": "*", + "folder": "*" + }, + "images": { + "filename": "*", + "folder": "*" + }, + "css": { + "filename": "*", + "folder": "*" + }, + "languages": { + "language": "*" + }, + "media": { + "filename": "*", + "folder": "*" + }, + "install": { + "sql": "*" + }, + "update": { + "sql": "*", + "schemas": "*" + }, + "uninstall": { + "sql": "*" + }, + "sql": { + "file": "*" + }, + "schemas": { + "schemapath": "*" + }, + "updateservers": { + "server": "*" + } + }, + "attributes": { + "extension": [ + "client", + "method", + "overwrite", + "type", + "version" + ], + "files": [ + "folder" + ], + "images": [ + "folder" + ], + "css": [ + "folder" + ], + "languages": [ + "folder" + ], + "language": [ + "client", + "tag" + ], + "position": [ + "value" + ], + "media": [ + "destination", + "folder" + ], + "file": [ + "charset", + "driver" + ], + "server": [ + "name", + "priority", + "type" + ], + "dlid": [ + "prefix", + "suffix" + ] + } +} \ No newline at end of file From f8320333aa60051d734ab5e3da46c42bc6a19c4b Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sat, 27 Feb 2021 02:12:32 +0300 Subject: [PATCH 30/40] support dlid attributes --- .../libraries/rules/xmlmanifest/dtd_component.json | 2 +- .../libraries/rules/xmlmanifest/dtd_language.json | 7 ++++++- .../libraries/rules/xmlmanifest/dtd_module.json | 6 +++++- .../libraries/rules/xmlmanifest/dtd_package.json | 4 ++++ .../libraries/rules/xmlmanifest/dtd_plugin.json | 6 +++++- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json index 96f9d61..c1d3b92 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json @@ -20,8 +20,8 @@ "media": "?", "administration": "?", "updateservers": "?", - "config": "?", "dlid": "?", + "config": "?", "namespace": "?" }, "administration": { diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json index e6002de..4c8c1c1 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json @@ -15,7 +15,8 @@ "media": "?", "fonts": "?", "update": "?", - "updateservers": "?" + "updateservers": "?", + "dlid": "?" }, "files": { "filename": "*", @@ -55,6 +56,10 @@ "name", "priority", "type" + ], + "dlid": [ + "prefix", + "suffix" ] } } \ No newline at end of file diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json index 1694b13..0480937 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json @@ -19,8 +19,8 @@ "languages": "?", "media": "?", "updateservers": "?", - "config": "?", "dlid": "?", + "config": "?", "namespace": "?" }, "files": { @@ -130,6 +130,10 @@ ], "field": [ "*" + ], + "dlid": [ + "prefix", + "suffix" ] } } \ No newline at end of file diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json index d46ca2e..f722723 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json @@ -67,6 +67,10 @@ "name", "priority", "type" + ], + "dlid": [ + "prefix", + "suffix" ] } } \ No newline at end of file diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json index b459b2c..8502fa8 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json @@ -19,8 +19,8 @@ "languages": "?", "media": "?", "updateservers": "?", - "config": "?", "dlid": "?", + "config": "?", "namespace": "?" }, "files": { @@ -131,6 +131,10 @@ ], "field": [ "*" + ], + "dlid": [ + "prefix", + "suffix" ] } } \ No newline at end of file From 5a4003c0da1f21adff256a341a0d17c89b22d7af Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Tue, 9 Mar 2021 23:26:33 +0300 Subject: [PATCH 31/40] warning for template w/o positions --- .../libraries/rules/xmlmanifest/dtd_template.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_template.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_template.json index efe3f9e..448cc13 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_template.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_template.json @@ -20,7 +20,7 @@ "css": "?", "languages": "?", "media": "?", - "positions": "!", + "positions": "=", "updateservers": "?", "dlid": "?", "config": "?" @@ -30,14 +30,17 @@ }, "files": { "filename": "*", + "files:file": "*", "folder": "*" }, "images": { "filename": "*", + "images:file": "*", "folder": "*" }, "css": { "filename": "*", + "css:file": "*", "folder": "*" }, "languages": { @@ -45,6 +48,7 @@ }, "media": { "filename": "*", + "media:file": "*", "folder": "*" }, "install": { From d023f84c3afff66bf0501d886e6860bf235e3560 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Tue, 9 Mar 2021 23:27:32 +0300 Subject: [PATCH 32/40] fix issue with processing of fileset>files in type=file extensions --- .../com_jedchecker/libraries/rules/xmlmanifest/dtd_file.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_file.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_file.json index 86ba299..5a6e836 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_file.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_file.json @@ -20,10 +20,11 @@ "dlid": "?" }, "fileset": { - "files": "=" + "files": "*" }, "files": { "filename": "*", + "files:file": "*", "folder": "*" }, "languages": { From 3961bbf3195b9cdc057daf917e89e8fb6491d92b Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Thu, 11 Mar 2021 17:20:50 +0300 Subject: [PATCH 33/40] Fix warning on types not supported by JED --- .../libraries/rules/xmlmanifest.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index b433331..cf89f20 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -87,11 +87,20 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule * * @var string[] */ - protected $types = array( + protected $joomlaTypes = array( 'component', 'file', 'language', 'library', 'module', 'package', 'plugin', 'template' ); + /** + * List of JED extension types + * + * @var string[] + */ + protected $jedTypes = array( + 'component', 'module', 'package', 'plugin' + ); + /** * Initiates the search and check * @@ -137,20 +146,24 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule // Check extension type $type = (string) $xml['type']; - if (!in_array($type, $this->types, true)) + if (!in_array($type, $this->joomlaTypes, true)) { $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_TYPE', $type)); return true; } + // 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)); + } + // Load DTD-like data for this extension type $json_filename = __DIR__ . '/xmlmanifest/dtd_' . $type . '.json'; if (!is_file($json_filename)) { - $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_TYPE_NOT_ACCEPTED', $type)); - return true; } From a426ccfd0e8c628b86930d30bd046018cfadbc5a Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sun, 4 Apr 2021 14:24:10 +0300 Subject: [PATCH 34/40] rule to found missed method="upgrade" --- .../com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini | 1 + .../com_jedchecker/libraries/rules/xmlmanifest.php | 6 ++++++ 2 files changed, 7 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 a5cd2d1..4067a09 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 @@ -89,3 +89,4 @@ COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND="Node <%1$s> contains multiple < COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD="Node <%1$s> contains unknown <%2$s> element" COM_JEDCHECKER_MANIFEST_EMPTY_CHILD="Found empty <%s> element" COM_JEDCHECKER_MANIFEST_MENU_UNUSED_ATTRIBUTE="Menu item attribute '%s' is not used with 'link' attribute" +COM_JEDCHECKER_MANIFEST_MISSED_METHOD_UPGRADE="Without the method="upgrade" attribute the extension package cannot be upgraded" diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index cf89f20..b0c48b6 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -167,6 +167,12 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule return true; } + // warn if method="upgrade" attribute is not found + if ((string) $xml['method'] !== 'upgrade') + { + $this->report->addWarning($file, JText::_('COM_JEDCHECKER_MANIFEST_MISSED_METHOD_UPGRADE')); + } + $data = json_decode(file_get_contents($json_filename), true); $this->DTDNodeRules = $data['nodes']; $this->DTDAttrRules = $data['attributes']; From 4ed9b2c64db00b780d50682d8d3aaaf32fb12685 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sun, 4 Apr 2021 14:26:31 +0300 Subject: [PATCH 35/40] rule to found missed/incorrent client attribute --- .../language/en-GB/en-GB.com_jedchecker.ini | 2 ++ .../libraries/rules/xmlmanifest.php | 15 +++++++++++++++ 2 files changed, 17 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 4067a09..387c5b3 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 @@ -90,3 +90,5 @@ COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD="Node <%1$s> contains unknown <%2 COM_JEDCHECKER_MANIFEST_EMPTY_CHILD="Found empty <%s> element" COM_JEDCHECKER_MANIFEST_MENU_UNUSED_ATTRIBUTE="Menu item attribute '%s' is not used with 'link' attribute" COM_JEDCHECKER_MANIFEST_MISSED_METHOD_UPGRADE="Without the method="upgrade" attribute the extension package cannot be upgraded" +COM_JEDCHECKER_MANIFEST_MISSED_ATTRIBUTE="The node <%1$s> doesn't contain required '%2$s' attribute" +COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE_VALUE="The node <%1$s> has attribute '%2$s' with unknown value "%3$s"" diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index b0c48b6..aa56c25 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -173,6 +173,21 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule $this->report->addWarning($file, JText::_('COM_JEDCHECKER_MANIFEST_MISSED_METHOD_UPGRADE')); } + // check 'client' attribute is "site" or "administrator" (for module/template only) + if ($type === 'module' || $type === 'template') + { + $client = (string) $xml['client']; + + if (!isset($xml['client'])) + { + $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ATTRIBUTE', $xml->getName(), 'client')); + } + elseif ($client !== 'site' && $client !== 'administrator') + { + $this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE_VALUE', $xml->getName(), 'client', $client)); + } + } + $data = json_decode(file_get_contents($json_filename), true); $this->DTDNodeRules = $data['nodes']; $this->DTDAttrRules = $data['attributes']; From f914e438c561e5102eaa1ed410be6cc73d11edce Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Tue, 9 Mar 2021 23:33:42 +0300 Subject: [PATCH 36/40] implement prefixed rules in DTD-json (to separate processing of files>file and sql>file nodes) --- .../libraries/rules/xmlmanifest.php | 60 +++++++++++++------ .../rules/xmlmanifest/dtd_component.json | 2 + .../rules/xmlmanifest/dtd_language.json | 3 + .../rules/xmlmanifest/dtd_library.json | 2 + .../rules/xmlmanifest/dtd_module.json | 5 ++ .../rules/xmlmanifest/dtd_package.json | 4 +- .../rules/xmlmanifest/dtd_plugin.json | 5 ++ 7 files changed, 62 insertions(+), 19 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index aa56c25..fd935bc 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -219,17 +219,28 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule } /** - * @param SimpleXMLElement $node XML node object - * @param string $name XML node name + * @param SimpleXMLElement $node XML node object + * @param string $ruleset rulest name in the DTD array * * @return void */ - protected function validateXml($node, $name) + protected function validateXml($node, $ruleset) { - // Check attributes - $DTDattributes = isset($this->DTDAttrRules[$name]) ? $this->DTDAttrRules[$name] : array(); + // Get node name + $name = $node->getName(); - if (isset($DTDattributes[0]) && $DTDattributes[0] !== '*') + // Check attributes + $DTDattributes = isset($this->DTDAttrRules[$ruleset]) ? $this->DTDAttrRules[$ruleset] : array(); + + if (count($DTDattributes) === 0) + { + // No known attributes for this node + foreach ($node->attributes() as $attr) + { + $this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, (string) $attr->getName()); + } + } + elseif ($DTDattributes[0] !== '*') // Skip node with arbitrary attributes (e.g. "field") { foreach ($node->attributes() as $attr) { @@ -244,22 +255,35 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule } // Check children nodes - if (!isset($this->DTDNodeRules[$name])) + $DTDchildRules = isset($this->DTDNodeRules[$ruleset]) ? $this->DTDNodeRules[$ruleset] : array(); + + // Child node name to ruleset name mapping + $DTDchildToRule = array(); + + if (count($DTDchildRules) === 0) { - // No children + // No known children for this node if ($node->count() > 0) { $this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN', $name); } } - elseif (!isset($this->DTDNodeRules[$name]['*'])) + elseif (!isset($DTDchildRules['*'])) // Skip node with arbitrary children { - $DTDchildren = $this->DTDNodeRules[$name]; - // 1) check required single elements - - foreach ($DTDchildren as $child => $mode) + foreach ($DTDchildRules as $childRuleset => $mode) { + $child = $childRuleset; + + if (strpos($child, ':') !== false) + { + // Split ruleset name into a prefix and the child node name + list ($prefix, $child) = explode(':', $child, 2); + } + + // Populate node-to-ruleset mapping + $DTDchildToRule[$child] = $childRuleset; + $count = $node->$child->count(); switch ($mode) @@ -300,14 +324,16 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule foreach ($childNames as $child) { - if (!isset($DTDchildren[$child])) + if (!isset($DTDchildToRule[$child])) { + // The node contains unknown child element $this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD', $name, $child); } else { - if ($DTDchildren[$child] === '?' && $node->$child->count() > 1) + if ($DTDchildRules[$DTDchildToRule[$child]] === '?' && $node->$child->count() > 1) { + // The node contains multiple child elements when single only is expected $this->errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child); } } @@ -336,9 +362,9 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule { $childName = $child->getName(); - if (isset($this->DTDNodeRules[$childName])) + if (isset($DTDchildToRule[$childName])) { - $this->validateXml($child, $childName); + $this->validateXml($child, $DTDchildToRule[$childName]); } } } diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json index c1d3b92..833eb82 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json @@ -33,6 +33,7 @@ }, "files": { "filename": "*", + "files:file": "*", "folder": "*" }, "languages": { @@ -40,6 +41,7 @@ }, "media": { "filename": "*", + "media:file": "*", "folder": "*" }, "submenu": { diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json index 4c8c1c1..fccf6e0 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json @@ -20,14 +20,17 @@ }, "files": { "filename": "*", + "files:file": "*", "folder": "*" }, "media": { "filename": "*", + "media:file": "*", "folder": "*" }, "fonts": { "filename": "*", + "fonts:file": "*", "folder": "*" }, "updateservers": { diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json index 1ab2d25..aa29c00 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json @@ -23,6 +23,7 @@ }, "files": { "filename": "*", + "files:file": "*", "folder": "*" }, "languages": { @@ -30,6 +31,7 @@ }, "media": { "filename": "*", + "media:file": "*", "folder": "*" }, "install": { diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json index 0480937..3b2b887 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json @@ -25,6 +25,7 @@ }, "files": { "filename": "*", + "files:file": "*", "folder": "*" }, "languages": { @@ -32,6 +33,7 @@ }, "media": { "filename": "*", + "media:file": "*", "folder": "*" }, "install": { @@ -77,6 +79,9 @@ "filename": [ "module" ], + "files:file": [ + "module" + ], "languages": [ "folder" ], diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json index f722723..9a43ba3 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json @@ -23,8 +23,8 @@ "blockChildUninstall": "?" }, "files": { - "file": "*", "filename": "*", + "files:file": "*", "folder": "*" }, "languages": { @@ -44,7 +44,7 @@ "files": [ "folder" ], - "file": [ + "files:file": [ "client", "group", "id", diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json index 8502fa8..b391747 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json @@ -25,6 +25,7 @@ }, "files": { "filename": "*", + "files:file": "*", "folder": "*" }, "languages": { @@ -32,6 +33,7 @@ }, "media": { "filename": "*", + "media:file": "*", "folder": "*" }, "install": { @@ -78,6 +80,9 @@ "filename": [ "plugin" ], + "files:file": [ + "plugin" + ], "languages": [ "folder" ], From 03f22df7d9646b649fc6a036f76c5a8cecf2d788 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sun, 4 Apr 2021 14:29:53 +0300 Subject: [PATCH 37/40] Mitigate error to a note for missed optional node --- .../language/en-GB/en-GB.com_jedchecker.ini | 1 + .../libraries/rules/xmlmanifest.php | 38 +++++++++++-------- 2 files changed, 24 insertions(+), 15 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 387c5b3..06644e7 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 @@ -85,6 +85,7 @@ COM_JEDCHECKER_MANIFEST_TYPE_NOT_ACCEPTED="Extension type '%s' is not accepted b COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE="Node <%1$s> has unknown attribute '%2$s'" COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN="Node <%s> has unknown child element" COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED="Node <%1$s> doesn't contain required <%2$s> element" +COM_JEDCHECKER_MANIFEST_MISSED_OPTIONAL="Node <%1$s> doesn't contain optional <%2$s> element" COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND="Node <%1$s> contains multiple <%2$s> elements" COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD="Node <%1$s> contains unknown <%2$s> element" COM_JEDCHECKER_MANIFEST_EMPTY_CHILD="Found empty <%s> element" diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index fd935bc..40e85f9 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -289,25 +289,33 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule switch ($mode) { case '!': - $errors =& $this->errors; + if ($count === 0) + { + // The node doesn't contain required child element + $this->errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED', $name, $child); + } + elseif ($count > 1) + { + // The node contains multiple child elements when single only is expected + $this->errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child); + } + break; + case '=': - $errors =& $this->warnings; + if ($count === 0) + { + // The node doesn't contain optional child element + $this->infos[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_OPTIONAL', $name, $child); + } + elseif ($count > 1) + { + // The node contains multiple child elements when single only is expected + $this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child); + } + break; - default: - continue 2; } - - if ($count === 0) - { - $errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED', $name, $child); - } - elseif ($count > 1) - { - $errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child); - } - - unset($errors); } // 2) check unknown/multiple elements From 1e0c1efec40452f5e9ea88644fd0a7f435091db3 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Tue, 9 Mar 2021 23:35:32 +0300 Subject: [PATCH 38/40] Allow packager and packagerurl in library extensions --- .../com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json index aa29c00..e93a036 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json @@ -11,6 +11,8 @@ "version": "!", "description": "=", "license": "?", + "packager": "?", + "packagerurl": "?", "scriptfile": "?", "install": "?", "update": "?", From 729d082bd2f2fa432ef932d9986d6adcc576a2ad Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Sun, 4 Apr 2021 15:12:02 +0300 Subject: [PATCH 39/40] fix Joomla codestyle --- .../com_jedchecker/libraries/rules/xmlmanifest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php index 40e85f9..5d4f119 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest.php @@ -160,20 +160,20 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule } // Load DTD-like data for this extension type - $json_filename = __DIR__ . '/xmlmanifest/dtd_' . $type . '.json'; + $jsonFilename = __DIR__ . '/xmlmanifest/dtd_' . $type . '.json'; - if (!is_file($json_filename)) + if (!is_file($jsonFilename)) { return true; } - // warn if method="upgrade" attribute is not found + // Warn if method="upgrade" attribute is not found if ((string) $xml['method'] !== 'upgrade') { $this->report->addWarning($file, JText::_('COM_JEDCHECKER_MANIFEST_MISSED_METHOD_UPGRADE')); } - // check 'client' attribute is "site" or "administrator" (for module/template only) + // Check 'client' attribute is "site" or "administrator" (for module/template only) if ($type === 'module' || $type === 'template') { $client = (string) $xml['client']; @@ -188,7 +188,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule } } - $data = json_decode(file_get_contents($json_filename), true); + $data = json_decode(file_get_contents($jsonFilename), true); $this->DTDNodeRules = $data['nodes']; $this->DTDAttrRules = $data['attributes']; From c60b397af7b4fe36b25ff84dcabfbceb522d3c3a Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 7 Apr 2021 10:36:46 +0300 Subject: [PATCH 40/40] add newline at end of dtd-json files --- .../libraries/rules/xmlmanifest/dtd_component.json | 2 +- .../com_jedchecker/libraries/rules/xmlmanifest/dtd_file.json | 2 +- .../libraries/rules/xmlmanifest/dtd_language.json | 2 +- .../com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json | 2 +- .../com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json | 2 +- .../com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json | 2 +- .../com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json | 2 +- .../libraries/rules/xmlmanifest/dtd_template.json | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json index 833eb82..5ca36f4 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_component.json @@ -117,4 +117,4 @@ "suffix" ] } -} \ No newline at end of file +} diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_file.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_file.json index 5a6e836..902338e 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_file.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_file.json @@ -83,4 +83,4 @@ "suffix" ] } -} \ No newline at end of file +} diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json index fccf6e0..ad20a0b 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_language.json @@ -65,4 +65,4 @@ "suffix" ] } -} \ No newline at end of file +} diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json index e93a036..b886e4f 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_library.json @@ -92,4 +92,4 @@ "suffix" ] } -} \ No newline at end of file +} diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json index 3b2b887..3becd97 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_module.json @@ -141,4 +141,4 @@ "suffix" ] } -} \ No newline at end of file +} diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json index 9a43ba3..f9a7930 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_package.json @@ -73,4 +73,4 @@ "suffix" ] } -} \ No newline at end of file +} diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json index b391747..1b5b555 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_plugin.json @@ -142,4 +142,4 @@ "suffix" ] } -} \ No newline at end of file +} diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_template.json b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_template.json index 448cc13..dbceb31 100644 --- a/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_template.json +++ b/administrator/components/com_jedchecker/libraries/rules/xmlmanifest/dtd_template.json @@ -116,4 +116,4 @@ "suffix" ] } -} \ No newline at end of file +}