Skip to content

Commit 07580cd

Browse files
authored
Merge pull request #45 from netlify/error-invalid-filename-chars
Check for invalid characters instead of escaping
2 parents 67f3bc3 + 51f78af commit 07580cd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

go/porcelain/deploy.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"hash"
1111
"io"
1212
"io/ioutil"
13-
"net/url"
1413
"os"
1514
"path/filepath"
1615
"strings"
@@ -179,6 +178,12 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
179178
}
180179
return nil, err
181180
}
181+
for name := range files.Files {
182+
if strings.ContainsAny(name, "#?") {
183+
return nil, fmt.Errorf("Invalid filename '%s'. Deployed filenames cannot contain # or ? characters", name)
184+
}
185+
}
186+
182187
options.files = files
183188

184189
functions, err := bundle(options.FunctionsDir, options.Observer)
@@ -399,8 +404,7 @@ func (n *Netlify) uploadFile(ctx context.Context, d *models.Deploy, f *FileBundl
399404

400405
switch t {
401406
case fileUpload:
402-
name := (&url.URL{Path: f.Name}).EscapedPath()
403-
params := operations.NewUploadDeployFileParams().WithDeployID(d.ID).WithPath(name).WithFileBody(f)
407+
params := operations.NewUploadDeployFileParams().WithDeployID(d.ID).WithPath(f.Name).WithFileBody(f)
404408
if timeout != 0 {
405409
params.SetTimeout(timeout)
406410
}

0 commit comments

Comments
 (0)