Permalink
Browse files

Adding fix for #14 to ensure req.url isn't getting passed to staticSe…

…nd on error, only if directory

Conflicts:

	lib/staticGzip.js
  • Loading branch information...
1 parent 6f44430 commit 02db5efba44bb9cf286d2e705df3e760cc966ed8 Dom Harrington committed with tomgco Feb 6, 2012
Showing with 14 additions and 1 deletion.
  1. +4 −1 lib/staticGzip.js
  2. +10 −0 test/staticGzipTest.js
View
@@ -156,8 +156,11 @@ exports = module.exports = function staticGzip(dirPath, options){
//Check file is not a directory
fs.stat(decodeURI(filename), function(err, stat) {
+ if (err) {
+ return pass(filename);
+ }
- if (err || stat.isDirectory()) {
+ if (stat.isDirectory()) {
return pass(req.url);
}
@@ -176,5 +176,15 @@ module.exports = {
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.