diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 577d857..afbdbb5 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -188,6 +188,11 @@ const DRUPAL_KILOBYTE = 1024; /** + * The maximum number of characters in a module or theme name. + */ +const DRUPAL_MODULE_NAME_MAX_LENGTH = 40; + +/** * Special system language code (only applicable to UI language). * * Refers to the language used in Drupal and module/theme source code. Drupal diff --git a/core/includes/module.inc b/core/includes/module.inc index f6d47b6..4984d6a 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -465,6 +465,13 @@ function module_enable($module_list, $enable_dependencies = TRUE) { unset($module_list[$module]); continue; } + // Throw an exception if the module name is too long. + if (strlen($module) > DRUPAL_MODULE_NAME_MAX_LENGTH) { + throw new \Exception(format_string('Module name %name is over the maximum allowed length of @max characters.', array( + '%name' => $module, + '@max' => DRUPAL_MODULE_NAME_MAX_LENGTH, + ))); + } $module_list[$module] = $module_data[$module]->sort; // Add dependencies to the list, with a placeholder weight. diff --git a/core/includes/theme.inc b/core/includes/theme.inc index bab2af5..cff98ee 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1515,6 +1515,14 @@ function theme_enable($theme_list) { $theme_config = config('system.theme'); $disabled_themes = config('system.theme.disabled'); foreach ($theme_list as $key) { + // Throw an exception if the theme name is too long. + if (strlen($key) > DRUPAL_MODULE_NAME_MAX_LENGTH) { + throw new \Exception(format_string('Theme name %name is over the maximum allowed length of @max characters.', array( + '%name' => $key, + '@max' => DRUPAL_MODULE_NAME_MAX_LENGTH, + ))); + } + // The value is not used; the weight is ignored for themes currently. $theme_config->set("enabled.$key", 0); $disabled_themes->clear($key);