Skip to content
Myr

Catch errors in multiple req.param(name, fn) handlers

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent 76e8bfa · Browse files · 3 files+28 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+28 added−6 removed

  • tests:+21 added−0 removed
  • other:+7 added−6 removed

3 files+28 added−6 removed

modified:lib/router/index.js+6 added-6 removed
351 unmodified lines
352 match: paramVal,353 value: paramVal354 };355356 try {357 return paramCallback();356 paramCallback();358 } catch (err) {359 return done(err);360 }357 }358359 // single param callbacks360 function paramCallback(err) {
10 unmodified lines
371 }372373 if (!fn) return param();374375 try {379 fn(req, res, paramCallback, paramVal, key.name);376 fn(req, res, paramCallback, paramVal, key.name);377 } catch (e) {378 paramCallback(e);379 }380 }381382 param();383};
153 unmodified lines
modified:test/app.param.js+21 added
235 unmodified lines
236 .get('/user/123')237 .expect(500, done);238 })239240 it('should catch thrown secondary error', function(done){241 var app = express();242243 app.param('id', function(req, res, next, val){244 process.nextTick(next);245 });246247 app.param('id', function(req, res, next, id){248 throw new Error('err!');249 });250251 app.get('/user/:id', function(req, res){252 var id = req.params.id;253 res.send('' + id);254 });255256 request(app)257 .get('/user/123')258 .expect(500, done);259 })260261 it('should defer to next route', function(done){262 var app = express();263264 app.param('id', function(req, res, next, id){
43 unmodified lines
modified:History.md+1 added
1 unmodified line
2==========34 * add explicit "Rosetta Flash JSONP abuse" protection5 - previous versions are not vulnerable; this is just explicit protection6 * catch errors in multiple `req.param(name, fn)` handlers7 * deprecate `res.redirect(url, status)` -- use `res.redirect(status, url)` instead8 * fix `res.send(status, num)` to send `num` as json (not error)9 * remove unnecessary escaping when `res.jsonp` returns JSON response10 * support non-string `path` in `app.use(path, fn)`
1784 unmodified lines