Navigation Menu

Skip to content

Commit

Permalink
Adding fix for tomgco#14 to ensure req.url isn't getting passed to st…
Browse files Browse the repository at this point in the history
…aticSend on error, only if directory

Conflicts:

	lib/staticGzip.js
  • Loading branch information
Dom Harrington authored and tomgco committed Feb 6, 2012
1 parent 6f44430 commit 02db5ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/staticGzip.js
Expand Up @@ -156,8 +156,11 @@ exports = module.exports = function staticGzip(dirPath, options){
//Check file is not a directory //Check file is not a directory


fs.stat(decodeURI(filename), function(err, stat) { fs.stat(decodeURI(filename), function(err, stat) {
if (err) {
return pass(filename);
}


if (err || stat.isDirectory()) { if (stat.isDirectory()) {
return pass(req.url); return pass(req.url);
} }


Expand Down
10 changes: 10 additions & 0 deletions test/staticGzipTest.js
Expand Up @@ -176,5 +176,15 @@ module.exports = {
res.statusCode.should.not.equal(404); res.statusCode.should.not.equal(404);
} }
); );
},
'Ensuring req.url isnt passed to staticSend on error': function() {
assert.response(getApp(),
{
url: '/etc/passwd'
},
function(res) {
res.statusCode.should.equal(404);
}
);
} }
}; };

0 comments on commit 02db5ef

Please sign in to comment.