Allow empty string matching in RegEx
What does this MR do and why?
Fixes match? method of the ::Gitlab::UntrustedRegexp ... (#477707 - closed)
The match? method immediately rejects empty strings even if the
regular expression itself would allow matching the empty string.
Due to how widely the method is used throughout the entire project, this behavior might be relied on in many places. This commit introduces a new parameter to explicitly allow matching empty strings when desired.
References
How to set up and validate locally
-
Create new project with the following two files:
component.yml:
spec: inputs: myinput: default: "" regex: \w{0,2} --- job: script: - echo my value is "$[[ inputs.myinput ]]".gitlab-ci.yml:
include: - local: component.yml -
Run a new pipeline
-
Observe
default value does not match required RegEx patternerror when using current code -
Observe pipeline getting created when using this branch
-
[Optional] Change
default: ""todefault: "test"incomponent.ymland observe pipeline getting created when using current code with no error message to see the difference in behavior – both the empty string andtestmatch the\w{0,2}RegEx, but the empty string causes a problem.