Permalink
Browse files

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

…nd on error, only if directory
  • Loading branch information...
Dom Harrington
Dom Harrington committed Feb 6, 2012
1 parent be826fc commit 2016a64f305e613c4d4dbd75938c7db1ee50b1bf
Showing with 15 additions and 1 deletion.
  1. +5 −1 lib/staticGzip.js
  2. +10 −0 test/staticGzipTest.js
View
@@ -154,7 +154,11 @@ exports = module.exports = function staticGzip(dirPath, options){
//Check file is not a directory
fs.stat(decodeURI(filename), function(err, stat) {
- if (err || stat.isDirectory()) {
+ if (err) {
+ return pass(filename);
+ }
+
+ if (stat.isDirectory()) {
return pass(req.url);
}
View
@@ -177,5 +177,15 @@ module.exports = {
res.statusCode.should.not.equal(404);
}
);
+ },
+ 'Ensuring req.url isnt passed to staticSend on error': function() {
+ assert.response(app,
+ {
+ url: '/etc/passwd'
+ },
+ function(res) {
+ res.statusCode.should.equal(404);
+ }
+ );
}
};

0 comments on commit 2016a64

Please sign in to comment.