From 3679f00fdded1f0f07d5d70f1b225da9d9508032 Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Fri, 1 Dec 2017 14:25:48 -0500 Subject: [PATCH 1/2] Check for invalid characters instead of escaping This matches how the API handles these characters. --- go/porcelain/deploy.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/go/porcelain/deploy.go b/go/porcelain/deploy.go index 0b427400..86557f50 100644 --- a/go/porcelain/deploy.go +++ b/go/porcelain/deploy.go @@ -10,7 +10,6 @@ import ( "hash" "io" "io/ioutil" - "net/url" "os" "path/filepath" "strings" @@ -179,6 +178,12 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy * } return nil, err } + for name := range files.Files { + if strings.ContainsAny(name, "#?") { + return nil, fmt.Errorf("Invalid filename '%s'. Deployed filenames cannot contain # or ? characters", name) + } + } + options.files = files functions, err := bundle(options.FunctionsDir, options.Observer) @@ -399,7 +404,7 @@ func (n *Netlify) uploadFile(ctx context.Context, d *models.Deploy, f *FileBundl switch t { case fileUpload: - name := (&url.URL{Path: f.Name}).EscapedPath() + name := f.Name params := operations.NewUploadDeployFileParams().WithDeployID(d.ID).WithPath(name).WithFileBody(f) if timeout != 0 { params.SetTimeout(timeout) From 51f78af00a2b14342e21978682d6e82344af673f Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Fri, 1 Dec 2017 14:29:08 -0500 Subject: [PATCH 2/2] Remove unnecessary var --- go/porcelain/deploy.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/go/porcelain/deploy.go b/go/porcelain/deploy.go index 86557f50..efa7aa33 100644 --- a/go/porcelain/deploy.go +++ b/go/porcelain/deploy.go @@ -404,8 +404,7 @@ func (n *Netlify) uploadFile(ctx context.Context, d *models.Deploy, f *FileBundl switch t { case fileUpload: - name := f.Name - params := operations.NewUploadDeployFileParams().WithDeployID(d.ID).WithPath(name).WithFileBody(f) + params := operations.NewUploadDeployFileParams().WithDeployID(d.ID).WithPath(f.Name).WithFileBody(f) if timeout != 0 { params.SetTimeout(timeout) }