Skip to content

Commit

Permalink
cl-fetch: make argument regexp strict
Browse files Browse the repository at this point in the history
  • Loading branch information
aclements committed Jul 13, 2019
1 parent b02510d commit c224846
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cl-fetch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var (
flagDry = flag.Bool("dry-run", false, "print but do not execute commands")
)

var clRe = regexp.MustCompile("[0-9]+|I[0-9a-f]{40}")
var clRe = regexp.MustCompile("^[0-9]+$|^I[0-9a-f]{40}$")

type Tag struct {
tag string
Expand All @@ -53,7 +53,7 @@ func main() {
}
for _, arg := range flag.Args() {
if !clRe.MatchString(arg) {
fmt.Fprintf(os.Stderr, "CL must be a CL number or Change-Id")
fmt.Fprintf(os.Stderr, "CL must be a CL number or Change-Id\n")
os.Exit(2)
}
queryParts = append(queryParts, "change:"+arg)
Expand Down

0 comments on commit c224846

Please sign in to comment.