Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Commit 1297fb3

Browse files
authored
Merge pull request #19 from netlify/fix-encoding-algo
encodeURI the file upload path
2 parents cb11357 + 1cd79a2 commit 1297fb3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/deploy/upload-files.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ async function uploadFiles(api, deployId, uploadList, { concurrentUpload, status
99
msg: `Uploading ${uploadList.length} files`,
1010
phase: 'start'
1111
})
12+
1213
const uploadFile = async (fileObj, index) => {
1314
const { normalizedPath, assetType, runtime } = fileObj
1415
const readStream = fs.createReadStream(fileObj.filepath)
@@ -24,15 +25,15 @@ async function uploadFiles(api, deployId, uploadList, { concurrentUpload, status
2425
response = await api.uploadDeployFile({
2526
body: readStream,
2627
deployId,
27-
path: normalizedPath
28+
path: encodeURI(normalizedPath)
2829
})
2930
break
3031
}
3132
case 'function': {
3233
response = await api.uploadDeployFunction({
3334
body: readStream,
3435
deployId,
35-
name: normalizedPath,
36+
name: encodeURI(normalizedPath),
3637
runtime
3738
})
3839
break

src/deploy/util.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ exports.defaultFilter = filename => {
2222

2323
// normalize windows paths to unix paths
2424
exports.normalizePath = relname => {
25+
if (relname.includes('#') || relname.includes('?')) {
26+
throw new Error(`Invalid filename ${relname}. Deployed filenames cannot contain # or ? characters`)
27+
}
2528
return (
2629
relname
2730
.split(path.sep)
28-
// .map(segment => encodeURIComponent(segment)) // TODO Messes up for paths with @ in them
31+
// .map(segment => encodeURI(segment)) // TODO I'm fairly certain we shouldn't encodeURI here, thats only for the file upload step
2932
.join('/')
3033
)
3134
}

0 commit comments

Comments
 (0)