X Tutup
Skip to content

Commit 4d90005

Browse files
author
Nate Smith
authored
Merge pull request cli#3772 from astroparam/escape-metacharacters
escape metacharacters in job name
2 parents 71547f4 + 20f915d commit 4d90005

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pkg/cmd/run/view/view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ func promptForJob(cs *iostreams.ColorScheme, jobs []shared.Job) (*shared.Job, er
462462
}
463463

464464
func logFilenameRegexp(job shared.Job, step shared.Step) *regexp.Regexp {
465-
re := fmt.Sprintf(`%s\/%d_.*\.txt`, job.Name, step.Number)
465+
re := fmt.Sprintf(`%s\/%d_.*\.txt`, regexp.QuoteMeta(job.Name), step.Number)
466466
return regexp.MustCompile(re)
467467
}
468468

pkg/cmd/run/view/view_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,17 @@ func Test_attachRunLog(t *testing.T) {
926926
},
927927
wantMatch: false,
928928
},
929+
{
930+
name: "escape metacharacters in job name",
931+
job: shared.Job{
932+
Name: "metacharacters .+*?()|[]{}^$ job",
933+
Steps: []shared.Step{{
934+
Name: "fob the barz",
935+
Number: 0,
936+
}},
937+
},
938+
wantMatch: false,
939+
},
929940
{
930941
name: "mismatching job name",
931942
job: shared.Job{

0 commit comments

Comments
 (0)
X Tutup