semaio / Magento2-ConfigImportExport

Import/Export configuration data in Magento 2 via CLI.
Open Software License 3.0
157 stars 59 forks source link

Environment variables that include numbers are not parsed #63

Closed JoostGB closed 1 year ago

JoostGB commented 1 year ago

General

Issue description

Environment variables that include numbers are not parsed.

Steps to reproduce

  1. Load environment variable INCLUDES_NUMBER_1=somevalue
  2. Use this for a configuration like: '%env(INCLUDES_NUMBER_1)%'
  3. Run setup:upgrade
  4. Expected result for the configuration should be somevalue
  5. Actual result: %env(INCLUDES_NUMBER_1)% (literal)

Suggested solution

Update the regex in Semaio\ConfigImportExport\Model\Resolver\EnvironmentVariableResolver from '/\%env\((?!PHP_|HTTP_|SERVER_|SCRIPT_|QUERY_|DOCUMENT_)([A-Z\_]{3,})\)\%/' to '/\%env\((?!PHP_|HTTP_|SERVER_|SCRIPT_|QUERY_|DOCUMENT_)([A-Z\_0-9]{3,})\)\%/'

And also create a testcase for this Setup: putenv('INCLUDES_NUMBER_1=testvalue5');

Validate: $this->assertEquals($this->environmentVariableResolver->resolveValue('%env(INCLUDES_NUMBER_1)%'), 'testvalue5');

therouv commented 1 year ago

@JoostGB Good catch! It makes sense to allow numbers, so I've implemented your suggested solution.