Disallow |, ( and ) in config object names

Created on 28 February 2024, about 1 year ago

Problem/Motivation

This is what \Drupal\Core\Config\ConfigBase::validateName() looks like:

    // The name must not contain any of the following characters:
    // : ? * < > " ' / \
    if (preg_match('/[:?*<>"\'\/\\\\]/', $name)) {
      throw new ConfigNameException("Invalid character in Config object name $name.");
    }

But …

Agreed we can question the wisdom of `ConfigBase::validateName()`, but that's not up to Recipes to change. Recipes should be able to install any config that is valid. So let's open a core issue to tighten that instead? :blush:

@chx requested in #1701014-63: Validate config object names to disallow | and a range of other characters (but not ( or )) and @xjm implemented it in #1701014-73: Validate config object names … but forgot |. So AFAICT the best course of action is to create a follow-up to tighten this in Drupal core 👍

#3420209-17: Allow config actions to be applied to multiple config entities using wildcards

This is that follow-up!

Steps to reproduce

$ touch "foo|bar.yml"
$ touch "foo(bar).yml"
$ ls -l *.yml
-rw-r--r--  1 wim.leers  staff  0 Feb 26 13:19 foo(bar).yml
-rw-r--r--  1 wim.leers  staff  0 Feb 26 13:18 foo|bar.yml

The existing test coverage was added in #1701014: Validate config object names . `@chx` requested over at #1701014-63: Validate config object names to disallow |, but not ( or ). @xjm implemented his suggestion 10 comments later at #1701014-73: Validate config object names , but apparently forgot about the pipe. So it seems like this was a simple oversight!

— source: https://git.drupalcode.org/project/distributions_recipes/-/merge_request...

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
Configuration 

Last updated 1 day ago

Created by

🇮🇳India narendraR Jaipur, India

Live updates comments and jobs are added and updated live.
  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024