diff options
author | TomSweeneyRedHat <tsweeney@redhat.com> | 2020-09-24 19:33:34 -0400 |
---|---|---|
committer | TomSweeneyRedHat <tsweeney@redhat.com> | 2020-10-13 19:30:08 -0400 |
commit | 33366a2cda518fafed0e72cf6e53b55abfa3c5e5 (patch) | |
tree | c35ad7ea24989b8259857dc0103dc28ab259b64e /libpod/image/filters.go | |
parent | d1ba9ce555099ad4cf2fd49c4598edaae0bfe0e4 (diff) | |
download | podman-33366a2cda518fafed0e72cf6e53b55abfa3c5e5.tar.gz podman-33366a2cda518fafed0e72cf6e53b55abfa3c5e5.tar.bz2 podman-33366a2cda518fafed0e72cf6e53b55abfa3c5e5.zip |
Convert Split() calls with an equal sign to SplitN()
After seeing #7759, I decided to look at the calls in
Podman and Buildah to see if we had issues with strings.Split()
calls where an "=" (equals) sign was in play and we expected
to split on only the first one.
There were only one or two that I found in here that I think
might have been troubling, the remainder are just adding
some extra safety.
I also had another half dozen or so that were checking length
expectations appropriately, those I left alone.
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Diffstat (limited to 'libpod/image/filters.go')
-rw-r--r-- | libpod/image/filters.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libpod/image/filters.go b/libpod/image/filters.go index db647954f..4aff0a7b5 100644 --- a/libpod/image/filters.go +++ b/libpod/image/filters.go @@ -82,7 +82,7 @@ func LabelFilter(ctx context.Context, labelfilter string) ResultFilter { // We need to handle both label=key and label=key=value return func(i *Image) bool { var value string - splitFilter := strings.Split(labelfilter, "=") + splitFilter := strings.SplitN(labelfilter, "=", 2) key := splitFilter[0] if len(splitFilter) > 1 { value = splitFilter[1] @@ -157,7 +157,7 @@ func (ir *Runtime) createFilterFuncs(filters []string, img *Image) ([]ResultFilt var filterFuncs []ResultFilter ctx := context.Background() for _, filter := range filters { - splitFilter := strings.Split(filter, "=") + splitFilter := strings.SplitN(filter, "=", 2) if len(splitFilter) < 2 { return nil, errors.Errorf("invalid filter syntax %s", filter) } |