diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index 59dbad3..bf0973a 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -89,6 +89,8 @@ class Config { * The configuration context used for this configuration object. */ public function __construct($name, StorageInterface $storage, ContextInterface $context) { + // Validate the configuration object name. + static::validateName($name); $this->name = $name; $this->storage = $storage; $this->context = $context; @@ -146,6 +148,8 @@ class Config { * The configuration object. */ public function setName($name) { + // Validate the configuration object name. + static::validateName($name); $this->name = $name; return $this; } @@ -153,6 +157,11 @@ class Config { /** * Validates the configuration object name. * + * A valid name must: + * - Be namespaced by its owner (i.e. contain at least one '.'). + * - Be shorter than Config::MAX_NAME_LENGTH characters. + * - Not contain any of the following characters: ? : * < > " ' / \ + * * @param string $name * The name of the configuration object. * @@ -161,7 +170,7 @@ class Config { * @see Config::MAX_NAME_LENGTH */ public static function validateName($name) { - // The name must be namespaced by owner. + // The name must be namespaced by its owner. if (strpos($name, '.') === FALSE) { throw new ConfigNameException(format_string('Missing namespace in Config object name @name.', array( '@name' => $name, @@ -404,8 +413,6 @@ class Config { * The configuration object. */ public function save() { - // Validate the configuration object name before saving. - static::validateName($this->name); if (!$this->isLoaded) { $this->load(); }