zip file from GET /__api__/appzip is corrupted when process.cwd() is a substring of some file's relative filepath
PhoneGap CLI, node & npm versions
phonegap 6.5.2
node 6.11.0
npm 3.10.10
Expected Behaviour
zip file received from GET /__api__/appzip should be in correct format
Actual Behaviour
Files written with wrong name within the zip leading to corrupted appzip file
Steps to Reproduce
Put your project in /app (like Heroku does)
process.cwd() === '/app'
Make a file beginning with app, e.g. app.js or app.css
When zipping file /app/www/js/app.js,
the code at https://github.com/phonegap/connect-phonegap/blob/f7c661e/lib/middleware/zip.js#L72 will generate a relative link of /www/js instead of /www/js/app.js, corrupting the zip file
Code that causes the problem
var output = pathWithSymlinks(filename).split(process.cwd())[1];
Error messages
$ unzip appzip
...
checkdir error: www/js exists but is not directory
unable to process www/js/otherJsFilesInTheSameFolder.js.
Note
This code exists in multiple places within the code base.
Original Issue
zip file from
GET /__api__/appzip
is corrupted whenprocess.cwd()
is a substring of some file's relative filepathPhoneGap CLI, node & npm versions
phonegap 6.5.2 node 6.11.0 npm 3.10.10
Expected Behaviour
zip file received from
GET /__api__/appzip
should be in correct formatActual Behaviour
Files written with wrong name within the zip leading to corrupted appzip file
Steps to Reproduce
Put your project in
/app
(like Heroku does)process.cwd() === '/app'
Make a file beginning withapp
, e.g.app.js
orapp.css
When zipping file/app/www/js/app.js
, the code at https://github.com/phonegap/connect-phonegap/blob/f7c661e/lib/middleware/zip.js#L72 will generate a relative link of/www/js
instead of/www/js/app.js
, corrupting the zip fileCode that causes the problem
var output = pathWithSymlinks(filename).split(process.cwd())[1];
Error messages
Note
This code exists in multiple places within the code base.