diff --git a/lib/OpenQA/Jobs/Constants.pm b/lib/OpenQA/Jobs/Constants.pm index 8afe3208012..7476d48754a 100644 --- a/lib/OpenQA/Jobs/Constants.pm +++ b/lib/OpenQA/Jobs/Constants.pm @@ -9,7 +9,7 @@ use Exporter 'import'; # define regex for validating test names in accordance with `JobScenarios-01.yaml` and `JobTemplates-01.yaml` # note: In contrast to the YAML schema a few more characters are allowed here as they are useful for manually # triggered jobs, e.g. via `openqa-clone-custom-git-refspec`. -use constant TEST_NAME_REGEX => qr|^[A-Za-z 0-9_*.+,:/#@%"'-]+$|; +use constant TEST_NAME_REGEX => qr|^[A-Za-z 0-9_*.+,:/#@%"'-]+\z|; # job states use constant { diff --git a/t/api/04-jobs.t b/t/api/04-jobs.t index e097b89f44b..20d72f4f5ef 100644 --- a/t/api/04-jobs.t +++ b/t/api/04-jobs.t @@ -826,7 +826,7 @@ subtest 'get job status' => sub { }; subtest 'validation of test name' => sub { - my @disallowed = ('spam=eggs', "spam\teggs"); + my @disallowed = ('spam=eggs', "spam\teggs", "spam\neggs", "spam eggs\n"); my @allowed = ('spam.eggs', 'spam+eggs', 'spam:"eggs"', 'spam@eggs', "spam 'eggs'"); $t->post_ok('/api/v1/jobs', form => {TEST => $_})->status_is(400, "test name $_ disallowed") for @disallowed; $t->json_is('/error' => 'The following settings are invalid: TEST', 'error for invalid test name returned');