Skip to content

Commit 5386c84

Browse files
committed
metadataPath validation replaces \ with / instead of complaining about it. closes #18"
1 parent f52717a commit 5386c84

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ function getEndOfCentralDirectoryRecord(self) {
228228

229229
function validateMetadataPath(metadataPath, isDirectory) {
230230
if (metadataPath === "") throw new Error("empty metadataPath");
231-
if (metadataPath.indexOf("\\") !== -1) throw new Error("invalid characters in path: " + metadataPath);
231+
metadataPath = metadataPath.replace(/\\/g, "/");
232232
if (/^[a-zA-Z]:/.test(metadataPath) || /^\//.test(metadataPath)) throw new Error("absolute path: " + metadataPath);
233233
if (metadataPath.split("/").indexOf("..") !== -1) throw new Error("invalid relative path: " + metadataPath);
234234
var looksLikeDirectory = /\/$/.test(metadataPath);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727
},
2828
"devDependencies": {
2929
"bl": "~0.9.3",
30-
"yauzl": "~2.0.0"
30+
"yauzl": "~2.3.1"
3131
}
3232
}

test/test.js

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var BufferList = require("bl");
1414
zipfile.addReadStream(fs.createReadStream(__filename), "readStream.txt", fileMetadata);
1515
var expectedContents = fs.readFileSync(__filename);
1616
zipfile.addBuffer(expectedContents, "with/directories.txt", fileMetadata);
17+
zipfile.addBuffer(expectedContents, "with\\windows-paths.txt", fileMetadata);
1718
zipfile.end(function(finalSize) {
1819
if (finalSize !== -1) throw new Error("finalSize is impossible to know before compression");
1920
zipfile.outputStream.pipe(new BufferList(function(err, data) {

0 commit comments

Comments
 (0)