diff --git a/pkg/cmd/run/view/view.go b/pkg/cmd/run/view/view.go index 17a8525f3..5dba471fc 100644 --- a/pkg/cmd/run/view/view.go +++ b/pkg/cmd/run/view/view.go @@ -462,7 +462,7 @@ func promptForJob(cs *iostreams.ColorScheme, jobs []shared.Job) (*shared.Job, er } func logFilenameRegexp(job shared.Job, step shared.Step) *regexp.Regexp { - re := fmt.Sprintf(`%s\/%d_.*\.txt`, job.Name, step.Number) + re := fmt.Sprintf(`%s\/%d_.*\.txt`, regexp.QuoteMeta(job.Name), step.Number) return regexp.MustCompile(re) } diff --git a/pkg/cmd/run/view/view_test.go b/pkg/cmd/run/view/view_test.go index 13ef80b7e..4e284b354 100644 --- a/pkg/cmd/run/view/view_test.go +++ b/pkg/cmd/run/view/view_test.go @@ -926,6 +926,17 @@ func Test_attachRunLog(t *testing.T) { }, wantMatch: false, }, + { + name: "escape metacharacters in job name", + job: shared.Job{ + Name: "metacharacters .+*?()|[]{}^$ job", + Steps: []shared.Step{{ + Name: "fob the barz", + Number: 0, + }}, + }, + wantMatch: false, + }, { name: "mismatching job name", job: shared.Job{