diff options
author | Qi Wang <qiwan@redhat.com> | 2019-07-22 15:15:38 -0400 |
---|---|---|
committer | Qi Wang <qiwan@redhat.com> | 2019-07-24 11:41:48 -0400 |
commit | a328e873c67af2cc469f57b3dc34b46a0f799558 (patch) | |
tree | afa67aa2008fda148f97f4b2b694cb9ed2caffb9 /cmd/podman/shared | |
parent | 2283471f8da7c3dc1a2cc6e1fe908c0fe7596d68 (diff) | |
download | podman-a328e873c67af2cc469f57b3dc34b46a0f799558.tar.gz podman-a328e873c67af2cc469f57b3dc34b46a0f799558.tar.bz2 podman-a328e873c67af2cc469f57b3dc34b46a0f799558.zip |
fix import not ignoring url path
fix #3609
Podman import used to check filename to only allow tarball path as a file. It should also allow an url as the doc mentioned. This PR allows the program to continue if the input is a valid URL
Signed-off-by: Qi Wang <qiwan@redhat.com>
Diffstat (limited to 'cmd/podman/shared')
-rw-r--r-- | cmd/podman/shared/parse/parse.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cmd/podman/shared/parse/parse.go b/cmd/podman/shared/parse/parse.go index a77002235..9fbc92fc3 100644 --- a/cmd/podman/shared/parse/parse.go +++ b/cmd/podman/shared/parse/parse.go @@ -7,6 +7,7 @@ import ( "bufio" "fmt" "net" + "net/url" "os" "regexp" "strings" @@ -162,3 +163,12 @@ func ValidateFileName(filename string) error { } return nil } + +// ValidURL checks a string urlStr is a url or not +func ValidURL(urlStr string) error { + _, err := url.ParseRequestURI(urlStr) + if err != nil { + return errors.Wrapf(err, "invalid url path: %q", urlStr) + } + return nil +} |