Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 02db5efba44bb9cf286d2e705df3e760cc966ed8 1 parent 6f44430
domharrington domharrington authored tomgco committed

Showing 2 changed files with 14 additions and 1 deletion. Show diff stats Hide diff stats

  1. +4 1 lib/staticGzip.js
  2. +10 0 test/staticGzipTest.js
5 lib/staticGzip.js
@@ -156,8 +156,11 @@ exports = module.exports = function staticGzip(dirPath, options){
156 156 //Check file is not a directory
157 157
158 158 fs.stat(decodeURI(filename), function(err, stat) {
  159 + if (err) {
  160 + return pass(filename);
  161 + }
159 162
160   - if (err || stat.isDirectory()) {
  163 + if (stat.isDirectory()) {
161 164 return pass(req.url);
162 165 }
163 166
10 test/staticGzipTest.js
@@ -176,5 +176,15 @@ module.exports = {
176 176 res.statusCode.should.not.equal(404);
177 177 }
178 178 );
  179 + },
  180 + 'Ensuring req.url isnt passed to staticSend on error': function() {
  181 + assert.response(getApp(),
  182 + {
  183 + url: '/etc/passwd'
  184 + },
  185 + function(res) {
  186 + res.statusCode.should.equal(404);
  187 + }
  188 + );
179 189 }
180 190 };

0 comments on commit 02db5ef

Please sign in to comment.
Something went wrong with that request. Please try again.