Package name schema regex is not validated

Created on 15 September 2023, 10 months ago
Updated 21 September 2023, 9 months ago

Problem/Motivation

working on 📌 Update module's merge request process for current core HEAD Fixed I found \Drupal\Tests\package_manager\Kernel\ComposerPluginsValidatorTest::testValidationAfterTrustingDuringPreCreate fails on 11.x

The test fails on core 11.x even without core merge request conversion

the failure is

Drupal\Tests\package_manager\Kernel\ComposerPluginsValidatorTest::testValidationAfterTrustingDuringPreCreate with data set "one UNsupported composer plugin — pretty package name" (array(true), array(array('not-cweagans/not-composer-patches', array('*'), array('AnyClass'), '6.1', 'composer-plugin')), array(Drupal\package_manager\ValidationResult Object (...)))
preg_match(): Unknown modifier '['

I think this is because our packge_name regex validation in package_manager.schema.yml is wrong.
If I try use the regex in isolation like this

$pattern = '/^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]|-{1,2})?[a-z0-9]+)*$/';
$result = preg_match($patterh2, 'any_');

I get the same "preg_match(): Unknown modifier '['" error as above

I am not sure why this doesn't fail on 10.1.x. If step debug in 10.1.x I don't get to the validator, \Symfony\Component\Validator\Constraints\RegexValidator, that causes the problem in 11.x

I have added test of the regex validation that shows we can save any package name in 10.1.x.

Steps to reproduce

Proposed resolution

fix the regex and make sure it is tested

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇺🇸United States tedbow Ithaca, NY, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024