Treat $$a as an escaped string in ExpandVariables::VARIABLES_REGEXP
When we enable the :variable_inside_variable FF, users will run into issues if they are leveraging escaping in their expressions. Let's say a user has defined the variable VAR_A=$$HOME, intending for the value to be expanded to $HOME by GitLab, and then to the actual HOME environment variable value by the Runner. In the current state, since ExpandVariables.VARIABLES_REGEXP is not smart enough to handle escaping, the value will get expanded to $ plus the value of $HOME by GitLab. The user will get a value for $HOME that is not the expected one (the one on the Runner where the build will be happening).
A user has come across this situation when we enabled the FF.
Current if a is defined as value_a, $$a will get resolved to $value_a. That is not the intended behavior, and ExpandVariables::VARIABLES_REGEXP should ignore references if the are escaped.
The following discussion from !54504 (merged) should be addressed:
-
@ayufan started a discussion: (+1 comment) I also noticed this being broken with this regex expansion:
ExpandVariables.variable_references('$$aaaa') => ['aaaa']Where-as it should return empty array, since the
$$is escaped.However, it appears that
ExpandVariables.expand('$$aaaa', {})is broken as well, as it should return$aaaa.This seems to be ~bug in regexp.