From 6c7b17c33ed7b14d162e9fbcccda339009b05b56 Mon Sep 17 00:00:00 2001 From: Harald Leithner Date: Sun, 11 Apr 2021 22:53:30 +0200 Subject: [PATCH] Prepare 3.9.26 release --- administrator/manifests/files/joomla.xml | 2 +- .../modules/mod_latest/mod_latest.xml | 1 + .../mod_latestactions/mod_latestactions.xml | 1 + .../modules/mod_logged/mod_logged.xml | 1 + administrator/modules/mod_login/mod_login.xml | 1 + administrator/modules/mod_menu/mod_menu.xml | 1 + .../mod_multilangstatus.xml | 1 + .../modules/mod_popular/mod_popular.xml | 1 + .../mod_privacy_dashboard.xml | 1 + .../modules/mod_quickicon/mod_quickicon.xml | 1 + .../modules/mod_sampledata/mod_sampledata.xml | 1 + .../mod_stats_admin/mod_stats_admin.xml | 1 + .../modules/mod_status/mod_status.xml | 1 + .../modules/mod_submenu/mod_submenu.xml | 1 + administrator/modules/mod_title/mod_title.xml | 1 + .../modules/mod_toolbar/mod_toolbar.xml | 1 + .../modules/mod_version/mod_version.xml | 1 + administrator/templates/isis/error.php | 2 +- libraries/src/Form/Rule/ModuleLayoutRule.php | 37 +++++++++++++++++++ libraries/src/Helper/ModuleHelper.php | 15 ++++++-- libraries/src/Version.php | 10 ++--- .../mod_articles_archive.xml | 1 + .../mod_articles_categories.xml | 1 + .../mod_articles_category.xml | 1 + .../mod_articles_latest.xml | 1 + .../mod_articles_news/mod_articles_news.xml | 3 +- .../mod_articles_popular.xml | 1 + modules/mod_banners/mod_banners.xml | 1 + modules/mod_breadcrumbs/mod_breadcrumbs.xml | 1 + modules/mod_custom/mod_custom.xml | 1 + modules/mod_feed/mod_feed.xml | 1 + modules/mod_finder/mod_finder.xml | 1 + modules/mod_footer/mod_footer.xml | 1 + modules/mod_languages/mod_languages.xml | 1 + modules/mod_login/mod_login.xml | 1 + modules/mod_menu/mod_menu.xml | 1 + modules/mod_random_image/mod_random_image.xml | 1 + .../mod_related_items/mod_related_items.xml | 1 + modules/mod_search/mod_search.xml | 1 + modules/mod_stats/mod_stats.xml | 1 + modules/mod_syndicate/mod_syndicate.xml | 1 + modules/mod_tags_popular/mod_tags_popular.xml | 1 + modules/mod_tags_similar/mod_tags_similar.xml | 1 + modules/mod_users_latest/mod_users_latest.xml | 1 + modules/mod_whosonline/mod_whosonline.xml | 1 + modules/mod_wrapper/mod_wrapper.xml | 1 + templates/protostar/error.php | 2 +- .../cms/installer/data/mod_finder.xml | 13 ++++--- .../cms/module/JModuleHelperTest.php | 35 +++++++++++++++++- 49 files changed, 139 insertions(+), 20 deletions(-) create mode 100644 libraries/src/Form/Rule/ModuleLayoutRule.php diff --git a/administrator/manifests/files/joomla.xml b/administrator/manifests/files/joomla.xml index 23f6bd646ddde..70a73410f13e3 100644 --- a/administrator/manifests/files/joomla.xml +++ b/administrator/manifests/files/joomla.xml @@ -6,7 +6,7 @@ www.joomla.org (C) 2005 - 2020 Open Source Matters. All rights reserved GNU General Public License version 2 or later; see LICENSE.txt - 3.9.26-dev + 3.9.26 April 2021 FILES_JOOMLA_XML_DESCRIPTION diff --git a/administrator/modules/mod_latest/mod_latest.xml b/administrator/modules/mod_latest/mod_latest.xml index f011d60fb4bf5..122d37b265ec1 100644 --- a/administrator/modules/mod_latest/mod_latest.xml +++ b/administrator/modules/mod_latest/mod_latest.xml @@ -73,6 +73,7 @@ type="modulelayout" label="JFIELD_ALT_LAYOUT_LABEL" description="JFIELD_ALT_MODULE_LAYOUT_DESC" + validate="moduleLayout" /> diff --git a/administrator/modules/mod_stats_admin/mod_stats_admin.xml b/administrator/modules/mod_stats_admin/mod_stats_admin.xml index da520de4c90ce..dd49611db6dca 100644 --- a/administrator/modules/mod_stats_admin/mod_stats_admin.xml +++ b/administrator/modules/mod_stats_admin/mod_stats_admin.xml @@ -77,6 +77,7 @@ type="modulelayout" label="JFIELD_ALT_LAYOUT_LABEL" description="JFIELD_ALT_MODULE_LAYOUT_DESC" + validate="moduleLayout" /> get('logoFile')) { - $logo = JUri::root() . $params->get('logoFile'); + $logo = htmlspecialchars(JUri::root() . $params->get('logoFile'), ENT_QUOTES, 'UTF-8'); } else { diff --git a/libraries/src/Form/Rule/ModuleLayoutRule.php b/libraries/src/Form/Rule/ModuleLayoutRule.php new file mode 100644 index 0000000000000..e53c00713acee --- /dev/null +++ b/libraries/src/Form/Rule/ModuleLayoutRule.php @@ -0,0 +1,37 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace Joomla\CMS\Form\Rule; + +defined('JPATH_PLATFORM') or die; + +use Joomla\CMS\Form\FormRule; + +/** + * Form Rule class for the Joomla Platform. + * + * @since 3.9.26 + */ +class ModuleLayoutRule extends FormRule +{ + /** + * The regular expression to use in testing a module layout field value. + * + * A valid module layout field value consists of + * - optionally a template name with only characters, numbers, hypens and + * underscores, which can also be just "_" for layouts provided by the + * module, followed by a colon + * - the base name of the layout file, not starting with a dot and with + * only characters, numbers, dots and hypens but no underscores (see + * method "getInput" of the "ModuleLayout" field). + * + * @var string + * @since 3.9.26 + */ + protected $regex = '^([A-Za-z0-9_-]+:)?[A-Za-z0-9-][A-Za-z0-9\.-]*$'; +} diff --git a/libraries/src/Helper/ModuleHelper.php b/libraries/src/Helper/ModuleHelper.php index 2b39b2df2708c..057d051ee6876 100644 --- a/libraries/src/Helper/ModuleHelper.php +++ b/libraries/src/Helper/ModuleHelper.php @@ -302,11 +302,20 @@ public static function getLayoutPath($module, $layout = 'default') $defaultLayout = $temp[1] ?: 'default'; } - // Build the template and base path for the layout - $tPath = JPATH_THEMES . '/' . $template . '/html/' . $module . '/' . $layout . '.php'; - $bPath = JPATH_BASE . '/modules/' . $module . '/tmpl/' . $defaultLayout . '.php'; $dPath = JPATH_BASE . '/modules/' . $module . '/tmpl/default.php'; + try + { + // Build the template and base path for the layout + $tPath = \JPath::check(JPATH_THEMES . '/' . $template . '/html/' . $module . '/' . $layout . '.php'); + $bPath = \JPath::check(JPATH_BASE . '/modules/' . $module . '/tmpl/' . $defaultLayout . '.php'); + } + catch (\Exception $e) + { + // On error fallback to the default path + return $dPath; + } + // If the template has a layout override use it if (file_exists($tPath)) { diff --git a/libraries/src/Version.php b/libraries/src/Version.php index 173fcc5c3d8b9..e94799e8569b4 100644 --- a/libraries/src/Version.php +++ b/libraries/src/Version.php @@ -60,7 +60,7 @@ final class Version * @var string * @since 3.8.0 */ - const EXTRA_VERSION = 'dev'; + const EXTRA_VERSION = ''; /** * Release version. @@ -78,7 +78,7 @@ final class Version * @since 3.5 * @deprecated 4.0 Use separated version constants instead */ - const DEV_LEVEL = '26-dev'; + const DEV_LEVEL = '26'; /** * Development status. @@ -86,7 +86,7 @@ final class Version * @var string * @since 3.5 */ - const DEV_STATUS = 'Development'; + const DEV_STATUS = 'Stable'; /** * Build number. @@ -111,7 +111,7 @@ final class Version * @var string * @since 3.5 */ - const RELDATE = '7-April-2021'; + const RELDATE = '13-April-2021'; /** * Release time. @@ -119,7 +119,7 @@ final class Version * @var string * @since 3.5 */ - const RELTIME = '22:51'; + const RELTIME = '15:00'; /** * Release timezone. diff --git a/modules/mod_articles_archive/mod_articles_archive.xml b/modules/mod_articles_archive/mod_articles_archive.xml index 516517f51f1d6..5737a92697f49 100644 --- a/modules/mod_articles_archive/mod_articles_archive.xml +++ b/modules/mod_articles_archive/mod_articles_archive.xml @@ -38,6 +38,7 @@ type="modulelayout" label="JFIELD_ALT_LAYOUT_LABEL" description="JFIELD_ALT_MODULE_LAYOUT_DESC" + validate="moduleLayout" /> - + @@ -223,6 +223,7 @@ type="modulelayout" label="JFIELD_ALT_LAYOUT_LABEL" description="JFIELD_ALT_MODULE_LAYOUT_DESC" + validate="moduleLayout" /> get('logoFile')) { - $logo = '' . $sitename . ''; + $logo = '' . $sitename . ''; } elseif ($params->get('sitetitle')) { diff --git a/tests/unit/suites/libraries/cms/installer/data/mod_finder.xml b/tests/unit/suites/libraries/cms/installer/data/mod_finder.xml index 5ea0ce34450f0..e9f26281384e9 100644 --- a/tests/unit/suites/libraries/cms/installer/data/mod_finder.xml +++ b/tests/unit/suites/libraries/cms/installer/data/mod_finder.xml @@ -28,7 +28,7 @@ name="searchfilter" type="searchfilter" label="MOD_FINDER_FIELDSET_BASIC_SEARCHFILTER_LABEL" - description="MOD_FINDER_FIELDSET_BASIC_SEARCHFILTER_DESCRIPTION" + description="MOD_FINDER_FIELDSET_BASIC_SEARCHFILTER_DESCRIPTION" default="" /> @@ -60,14 +60,15 @@ name="layout" type="modulelayout" label="JFIELD_ALT_LAYOUT_LABEL" - description="JFIELD_ALT_MODULE_LAYOUT_DESC" + description="JFIELD_ALT_MODULE_LAYOUT_DESC" + validate="moduleLayout" /> @@ -75,7 +76,7 @@ name="field_size" type="text" label="MOD_FINDER_FIELDSET_ADVANCED_FIELD_SIZE_LABEL" - description="MOD_FINDER_FIELDSET_ADVANCED_FIELD_SIZE_DESCRIPTION" + description="MOD_FINDER_FIELDSET_ADVANCED_FIELD_SIZE_DESCRIPTION" default="25" filter="integer" /> @@ -84,7 +85,7 @@ name="alt_label" type="text" label="MOD_FINDER_FIELDSET_ADVANCED_ALT_LABEL" - description="MOD_FINDER_FIELDSET_ADVANCED_ALT_DESCRIPTION" + description="MOD_FINDER_FIELDSET_ADVANCED_ALT_DESCRIPTION" /> diff --git a/tests/unit/suites/libraries/cms/module/JModuleHelperTest.php b/tests/unit/suites/libraries/cms/module/JModuleHelperTest.php index 03e1a3a3aa434..d9cc77a81b60e 100644 --- a/tests/unit/suites/libraries/cms/module/JModuleHelperTest.php +++ b/tests/unit/suites/libraries/cms/module/JModuleHelperTest.php @@ -159,10 +159,41 @@ public function testIsEnabled() */ public function testGetLayoutPath() { + // Default layout path + $dPath = JPATH_ROOT . '/modules/mod_search/tmpl/default.php'; + + // Base layout path + $bPath = JPATH_ROOT . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'mod_search' + . DIRECTORY_SEPARATOR . 'tmpl' . DIRECTORY_SEPARATOR . 'default.php'; + $this->assertEquals( JModuleHelper::getLayoutPath('mod_search'), - JPATH_ROOT . '/modules/mod_search/tmpl/default.php', - 'The default layout path for mod_search should be returned' + $bPath, + 'The base layout path for mod_search should be returned if no layout parameter is given' + ); + + $this->assertEquals( + JModuleHelper::getLayoutPath('mod_search', '../template:default'), + $dPath, + 'The default layout path for mod_search should be returned if invalid template is given in layout parameter' + ); + + $this->assertEquals( + JModuleHelper::getLayoutPath('mod_search', 'bad-template:default'), + $bPath, + 'The base layout path for mod_search should be returned if not existing template is given in layout parameter' + ); + + $this->assertEquals( + JModuleHelper::getLayoutPath('mod_search', '_:../default'), + $dPath, + 'The default layout path for mod_search should be returned if invalid layout file is given in layout parameter' + ); + + $this->assertEquals( + JModuleHelper::getLayoutPath('mod_search', '_:bad-layout-file'), + $dPath, + 'The default layout path for mod_search should be returned if not existing layout file is given in layout parameter' ); } }