Merge tag '4.13.4'
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 · parents 2c668f8, 193bed2 · Browse files · 15 files·+261 added−79 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
15 files+261 added−79 removed
- tests:+94 added−22 removed
- other:+167 added−57 removed
Provenance
- Commit
7cafdb5- Tree
3acef65- Author
Douglas Christopher Wilson <doug@somethingdoug.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent 1
2c668f8- Parent 2
193bed2
15 files changed+261 added−79 removed
modified:examples/view-constructor/index.js+2 added-2 removed
21 unmodified lines222324252626272829304 unmodified lines353637383939404142434 unmodified lines21 unmodified lines }});
// pointing to a particular github repo to load files from itapp.set('views', 'strongloop/express');app.set('views', 'expressjs/express');
// register a new view constructorapp.set('view', GithubView);
4 unmodified lines res.render('examples/markdown/views/index.md', { title: 'Example' });});
app.get('/Readme.md', function(req, res){ // rendering a view from https://github.com/strongloop/express/blob/master/Readme.md // rendering a view from https://github.com/expressjs/express/blob/master/Readme.md res.render('Readme.md');});
/* istanbul ignore next */4 unmodified linesmodified:examples/web-service/index.js+1 added-1 removed
47 unmodified lines4849505152525354555656 unmodified lines47 unmodified lines
// these two objects will serve as our faux database
var repos = [ { name: 'express', url: 'http://github.com/strongloop/express' } { name: 'express', url: 'http://github.com/expressjs/express' } , { name: 'stylus', url: 'http://github.com/learnboost/stylus' } , { name: 'cluster', url: 'http://github.com/learnboost/cluster' }];
56 unmodified linesmodified:lib/application.js+1 added-1 removed
506 unmodified lines507 * // ...508 * })509 *510 * @param {String} name511- * @param {String|Function} options or fn511+ * @param {Object|Function} options or fn512 * @param {Function} callback513 * @public514 */515 114 unmodified linesmodified:test/acceptance/web-service.js+1 added-1 removed
51 unmodified lines52 request(app)53 .get('/api/repos?api-key=foo')54 .expect('Content-Type', 'application/json; charset=utf-8')55 .expect(/"name":"express"/)56- .expect(/"url":"http:\/\/github.com\/strongloop\/express"/)56+ .expect(/"url":"http:\/\/github.com\/expressjs\/express"/)57 .expect(200, done)58 })59 })60 })45 unmodified linesmodified:test/app.router.js+48 added
318 unmodified lines319 .get('/user/id:10/name:tj/profile')320 .expect(200, '[["0","10"],["1","tj"],["2","profile"]]', done);321 })322 323+ it('should merge numeric indices req.params when parent has same number', function(done){324+ var app = express();325+ var router = new express.Router({ mergeParams: true });326+327+ router.get('/name:(\\w+)', function(req, res){328+ var keys = Object.keys(req.params).sort();329+ res.send(keys.map(function(k){ return [k, req.params[k]] }));330+ });331+332+ app.use('/user/id:(\\d+)', router);333+334+ request(app)335+ .get('/user/id:10/name:tj')336+ .expect(200, '[["0","10"],["1","tj"]]', done);337+ })338+339 it('should ignore invalid incoming req.params', function(done){340 var app = express();341 var router = new express.Router({ mergeParams: true });342 10 unmodified lines353 request(app)354 .get('/user/tj')355 .expect(200, '[["name","tj"]]', done);356 })357+358+ it('should restore req.params', function(done){359+ var app = express();360+ var router = new express.Router({ mergeParams: true });361+362+ router.get('/user:(\\w+)/*', function (req, res, next) {363+ next();364+ });365+366+ app.use('/user/id:(\\d+)', function (req, res, next) {367+ router(req, res, function (err) {368+ var keys = Object.keys(req.params).sort();369+ res.send(keys.map(function(k){ return [k, req.params[k]] }));370+ });371+ });372+373+ request(app)374+ .get('/user/id:42/user:tj/profile')375+ .expect(200, '[["0","42"]]', done);376+ })377 })378 379 describe('trailing slashes', function(){380 it('should be optional by default', function(done){375 unmodified lines756 .get('/users/tj/edit')757 .expect('editing tj (old)', cb);758 })759 760+ it('should work inside literal paranthesis', function(done){761+ var app = express();762+763+ app.get('/:user\\(:op\\)', function(req, res){764+ res.end(req.params.op + 'ing ' + req.params.user);765+ });766+767+ request(app)768+ .get('/tj(edit)')769+ .expect('editing tj', done);770+ })771+772 it('should work in array of paths', function(done){773 var app = express();774 var cb = after(2, done);775 259 unmodified linesmodified:test/app.routes.error.js+16 added
1 unmodified line2 , request = require('supertest');3 4 describe('app', function(){5 describe('.VERB()', function(){6+ it('should not get invoked without error handler on error', function(done) {7+ var app = express();8+9+ app.use(function(req, res, next){10+ next(new Error('boom!'))11+ });12+13+ app.get('/bar', function(req, res){14+ res.send('hello, world!');15+ });16+17+ request(app)18+ .post('/bar')19+ .expect(500, /Error: boom!/, done);20+ });21+22 it('should only call an error handling routing callback when an error is propagated', function(done){23 var app = express();24 25 var a = false;34 unmodified linesmodified:test/res.redirect.js+15 added-21 removed
1 2+var http = require('http');2-var express = require('../')3- , request = require('supertest');3+var express = require('..');4+var request = require('supertest');5 6 describe('res', function(){7 describe('.redirect(url)', function(){8 it('should default to a 302 redirect', function(done){74 unmodified lines83 84 request(app)85 .get('/')86 .set('Accept', 'text/html')86- .end(function(err, res){87- res.headers.should.have.property('location', 'http://google.com');88- res.text.should.equal('<p>Moved Temporarily. Redirecting to <a href="http://google.com">http://google.com</a></p>');89- done();90- })87+ .expect('Content-Type', /html/)88+ .expect('Location', 'http://google.com')89+ .expect(302, '<p>' + http.STATUS_CODES[302] + '. Redirecting to <a href="http://google.com">http://google.com</a></p>', done);90 })91 92 it('should escape the url', function(done){93 var app = express();5 unmodified lines99 request(app)100 .get('/')101 .set('Host', 'http://example.com')102 .set('Accept', 'text/html')104- .end(function(err, res){105- res.text.should.equal('<p>Moved Temporarily. Redirecting to <a href="<lame>"><lame></a></p>');106- done();107- })103+ .expect('Content-Type', /html/)104+ .expect('Location', '<lame>')105+ .expect(302, '<p>' + http.STATUS_CODES[302] + '. Redirecting to <a href="<lame>"><lame></a></p>', done);106 })107 108 it('should include the redirect type', function(done){109 var app = express();21 unmodified lines131 132 request(app)133 .get('/')134 .set('Accept', 'text/plain, */*')137- .end(function(err, res){138- res.headers.should.have.property('location', 'http://google.com');139- res.headers.should.have.property('content-length', '51');140- res.text.should.equal('Moved Temporarily. Redirecting to http://google.com');141- done();142- })135+ .expect('Content-Type', /plain/)136+ .expect('Location', 'http://google.com')137+ .expect(302, http.STATUS_CODES[302] + '. Redirecting to http://google.com', done);138 })139 140 it('should encode the url', function(done){141 var app = express();5 unmodified lines147 request(app)148 .get('/')149 .set('Host', 'http://example.com')150 .set('Accept', 'text/plain, */*')156- .end(function(err, res){157- res.text.should.equal('Moved Temporarily. Redirecting to http://example.com/?param=%3Cscript%3Ealert(%22hax%22);%3C/script%3E');158- done();159- })151+ .expect('Content-Type', /plain/)152+ .expect('Location', 'http://example.com/?param=<script>alert("hax");</script>')153+ .expect(302, http.STATUS_CODES[302] + '. Redirecting to http://example.com/?param=%3Cscript%3Ealert(%22hax%22);%3C/script%3E', done);154 })155 156 it('should include the redirect type', function(done){157 var app = express();35 unmodified linesmodified:test/res.send.js+14 added
3 unmodified lines4 var methods = require('methods');5 var request = require('supertest');6 7 describe('res', function(){8+ describe('.send()', function(){9+ it('should set body to ""', function(done){10+ var app = express();11+12+ app.use(function(req, res){13+ res.send();14+ });15+16+ request(app)17+ .get('/')18+ .expect(200, '', done);19+ })20+ })21+22 describe('.send(null)', function(){23 it('should set body to ""', function(done){24 var app = express();25 533 unmodified linesmodified:.travis.yml+3 added-3 removed
1 language: node_js2 node_js:3 - "0.10"4 - "0.12"5- - "1.0"5 - "1.8"7- - "2.0"8- - "2.3"6+ - "2.5"7+ - "3.3"8+ - "4.2"9 sudo: false10 before_install: "npm rm --save-dev connect-redis"11 script: "npm run-script test-ci"12 after_script: "npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls"modified:appveyor.yml+3 added-3 removed
1 environment:2 matrix:3 - nodejs_version: "0.10"4 - nodejs_version: "0.12"5- - nodejs_version: "1.0"5 - nodejs_version: "1.8"7- - nodejs_version: "2.0"8- - nodejs_version: "2.3"6+ - nodejs_version: "2.5"7+ - nodejs_version: "3.3"8+ - nodejs_version: "4.2"9 install:10 - ps: Install-Product node $env:nodejs_version11 - npm rm --save-dev connect-redis12 - npm install6 unmodified linesmodified:Contributing.md+1 added-5 removed
1+# Contributing2 2-## Website Issues3-4-Issues for the expressjs.com website go here https://github.com/strongloop/expressjs.com5-3 ## PRs and Code contributions4 5 * Tests must pass.6 * Follow existing coding style.11 unmodified lines18 * Clear description of the expected result.19 * Steps you have taken to debug it yourself.20 21 If you post a question and do not outline the above items or make it easy for us to understand and reproduce your issue, it will be closed.25-modified:History.md+71 added
33 unmodified lines34 - `req.query` is now a getter instead of a plain property35 * add:36 - `app.router` is a reference to the base router37 38+4.13.4 / 2016-01-2139+===================40+41+ * deps: content-disposition@0.5.142+ - perf: enable strict mode43+ * deps: cookie@0.1.544+ - Throw on invalid values provided to `serialize`45+ * deps: depd@~1.1.046+ - Support web browser loading47+ - perf: enable strict mode48+ * deps: escape-html@~1.0.349+ - perf: enable strict mode50+ - perf: optimize string replacement51+ - perf: use faster string coercion52+ * deps: finalhandler@0.4.153+ - deps: escape-html@~1.0.354+ * deps: merge-descriptors@1.0.155+ - perf: enable strict mode56+ * deps: methods@~1.1.257+ - perf: enable strict mode58+ * deps: parseurl@~1.3.159+ - perf: enable strict mode60+ * deps: proxy-addr@~1.0.1061+ - deps: ipaddr.js@1.0.562+ - perf: enable strict mode63+ * deps: range-parser@~1.0.364+ - perf: enable strict mode65+ * deps: send@0.13.166+ - deps: depd@~1.1.067+ - deps: destroy@~1.0.468+ - deps: escape-html@~1.0.369+ - deps: range-parser@~1.0.370+ * deps: serve-static@~1.10.271+ - deps: escape-html@~1.0.372+ - deps: parseurl@~1.3.073+ - deps: send@0.13.174+75+4.13.3 / 2015-08-0276+===================77+78+ * Fix infinite loop condition using `mergeParams: true`79+ * Fix inner numeric indices incorrectly altering parent `req.params`80+81+4.13.2 / 2015-07-3182+===================83+84+ * deps: accepts@~1.2.1285+ - deps: mime-types@~2.1.486+ * deps: array-flatten@1.1.187+ - perf: enable strict mode88+ * deps: path-to-regexp@0.1.789+ - Fix regression with escaped round brackets and matching groups90+ * deps: type-is@~1.6.691+ - deps: mime-types@~2.1.492+93 4.13.1 / 2015-07-0594 ===================95 96 * deps: accepts@~1.2.10859 unmodified lines956 - `app.router()` - returns the app Router instance957 - `app.route()` - Proxy to the app's `Router#route()` method to create a new route958 - Router & Route - public API959 960+3.21.2 / 2015-07-31961+===================962+963+ * deps: connect@2.30.2964+ - deps: body-parser@~1.13.3965+ - deps: compression@~1.5.2966+ - deps: errorhandler@~1.4.2967+ - deps: method-override@~2.3.5968+ - deps: serve-index@~1.7.2969+ - deps: type-is@~1.6.6970+ - deps: vhost@~3.0.1971+ * deps: vary@~1.0.1972+ - Fix setting empty header from empty `field`973+ - perf: enable strict mode974+ - perf: remove argument reassignments975+976 3.21.1 / 2015-07-05977 ===================978 979 * deps: basic-auth@~1.0.32120 unmodified linesmodified:package.json+31 added-32 removed
11 unmodified lines12 "Roman Shtylman <shtylman+expressjs@gmail.com>",13 "Young Jae Sim <hanul@hanul.me>"14 ],15 "license": "MIT",16- "repository": "strongloop/express",17- "homepage": "http://expressjs.com/",16+ "repository": "expressjs/express",17 "keywords": [18 "express",19 "framework",20 "sinatra",4 unmodified lines25 "app",26 "api"27 ],28 "dependencies": {30- "accepts": "~1.2.10",31- "array-flatten": "1.1.0",32- "content-disposition": "0.5.0",29+ "accepts": "~1.2.12",30+ "array-flatten": "1.1.1",31+ "content-disposition": "0.5.1",32 "content-type": "~1.0.1",34- "cookie": "0.1.3",33+ "cookie": "0.1.5",34 "cookie-signature": "1.0.6",35 "debug": "~2.2.0",37- "depd": "~1.0.1",38- "escape-html": "1.0.2",36+ "depd": "~1.1.0",37+ "escape-html": "~1.0.3",38 "etag": "~1.7.0",40- "finalhandler": "0.4.0",39+ "finalhandler": "0.4.1",40 "fresh": "0.3.0",42- "merge-descriptors": "1.0.0",43- "methods": "~1.1.1",41+ "merge-descriptors": "1.0.1",42+ "methods": "~1.1.2",43 "on-finished": "~2.3.0",45- "parseurl": "~1.3.0",44+ "parseurl": "~1.3.1",45 "path-is-absolute": "1.0.0",47- "path-to-regexp": "0.1.6",48- "proxy-addr": "~1.0.8",46+ "path-to-regexp": "0.1.7",47+ "proxy-addr": "~1.0.10",48 "qs": "4.0.0",50- "range-parser": "~1.0.2",49+ "range-parser": "~1.0.3",50 "router": "~1.1.2",52- "send": "0.13.0",53- "serve-static": "~1.10.0",54- "type-is": "~1.6.4",55- "vary": "~1.0.0",56- "utils-merge": "1.0.0"51+ "send": "0.13.1",52+ "serve-static": "~1.10.2",53+ "type-is": "~1.6.6",54+ "utils-merge": "1.0.0",55+ "vary": "~1.0.1"56 },57 "devDependencies": {58 "after": "0.8.1",60- "ejs": "2.3.2",61- "istanbul": "0.3.9",62- "marked": "0.3.3",63- "mocha": "2.2.5",64- "should": "7.0.1",65- "supertest": "1.0.1",66- "body-parser": "~1.13.2",67- "connect-redis": "~2.3.0",68- "cookie-parser": "~1.3.5",59+ "ejs": "2.3.4",60+ "istanbul": "0.4.2",61+ "marked": "0.3.5",62+ "mocha": "2.3.4",63+ "should": "7.1.1",64+ "supertest": "1.1.0",65+ "body-parser": "~1.14.2",66+ "connect-redis": "~2.4.1",67+ "cookie-parser": "~1.4.1",68 "cookie-session": "~1.2.0",70- "express-session": "~1.11.3",69+ "express-session": "~1.13.0",70 "jade": "~1.11.0",72- "method-override": "~2.3.3",71+ "method-override": "~2.3.5",72 "morgan": "~1.6.1",73 "multiparty": "~4.1.2",75- "vhost": "~3.0.0"74+ "vhost": "~3.0.1"75 },76 "engines": {77 "node": ">= 0.10.0"78 },14 unmodified linesmodified:Readme.md+10 added-10 removed
35 unmodified lines36 * Executable for generating applications quickly37 38 ## Docs & Community39 40- * [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/strongloop/expressjs.com)]40 * [#express](https://webchat.freenode.net/?channels=express) on freenode IRC41 * [Github Organization](https://github.com/expressjs) for Official Middleware & Modules43- * Visit the [Wiki](https://github.com/strongloop/express/wiki)42 * [Google Group](https://groups.google.com/group/express-js) for discussion43+ * [Gitter](https://gitter.im/expressjs/express) for support and discussion44 * [Русскоязычная документация](http://jsman.ru/express/)46- * [한국어 문서](http://expressjs.kr) - [[website repo](https://github.com/Hanul/expressjs.kr)]45 48-**PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/strongloop/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/strongloop/express/wiki/New-features-in-4.x).46+###Security Issues47 48+If you discover a security vulnerability in Express, please see [Security Policies and Procedures](Security.md).49+50 ## Quick Start51 52 The quickest way to get started with express is to utilize the executable [`express(1)`](https://github.com/expressjs/generator) to generate an application as shown below:53 35 unmodified lines89 90 To view the examples, clone the Express repo and install the dependencies:91 92 ```bash93-$ git clone git://github.com/strongloop/express.git --depth 193+$ git clone git://github.com/expressjs/express.git --depth 194 $ cd express95 $ npm install96 ```97 17 unmodified lines115 The original author of Express is [TJ Holowaychuk](https://github.com/tj) [![TJ's Gratipay][gratipay-image-visionmedia]][gratipay-url-visionmedia]116 117 The current lead maintainer is [Douglas Christopher Wilson](https://github.com/dougwilson) [![Doug's Gratipay][gratipay-image-dougwilson]][gratipay-url-dougwilson]118 119-[List of all contributors](https://github.com/strongloop/express/graphs/contributors)119+[List of all contributors](https://github.com/expressjs/express/graphs/contributors)120 121 ## License122 123 [MIT](LICENSE)1 unmodified line125 [npm-image]: https://img.shields.io/npm/v/express.svg126 [npm-url]: https://npmjs.org/package/express127 [downloads-image]: https://img.shields.io/npm/dm/express.svg128 [downloads-url]: https://npmjs.org/package/express129-[travis-image]: https://img.shields.io/travis/strongloop/express/master.svg?label=linux130-[travis-url]: https://travis-ci.org/strongloop/express129+[travis-image]: https://img.shields.io/travis/expressjs/express/master.svg?label=linux130+[travis-url]: https://travis-ci.org/expressjs/express131 [appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/express/master.svg?label=windows132 [appveyor-url]: https://ci.appveyor.com/project/dougwilson/express133-[coveralls-image]: https://img.shields.io/coveralls/strongloop/express/master.svg134-[coveralls-url]: https://coveralls.io/r/strongloop/express?branch=master133+[coveralls-image]: https://img.shields.io/coveralls/expressjs/express/master.svg134+[coveralls-url]: https://coveralls.io/r/expressjs/express?branch=master135 [gratipay-image-visionmedia]: https://img.shields.io/gratipay/visionmedia.svg136 [gratipay-url-visionmedia]: https://gratipay.com/visionmedia/137 [gratipay-image-dougwilson]: https://img.shields.io/gratipay/dougwilson.svg138 [gratipay-url-dougwilson]: https://gratipay.com/dougwilson/added:Security.md+44 added
1+# Security Policies and Procedures2+3+This document outlines security procedures and general policies for the Express4+project.5+6+ * [Reporting a Bug](#reporting-a-bug)7+ * [Disclosure Policy](#disclosure-policy)8+ * [Receiving Security Updates](#receiving-security-updates)9+ * [Comments on this Policy](#comments-on-this-policy)10+11+## Reporting a Bug12+13+The Express team and community take all security bugs in Express seriously.14+Thank you for improving the security of Express. We appreciate your efforts and15+responsible disclosure and will make every effort to acknowledge your16+contributions.17+18+Report security bugs by emailing the lead maintainer in the Readme.md file.19+20+The lead maintainer will acknowledge your email within 48 hours, and will send a21+more detailed response within 48 hours indicating the next steps in handling22+your report. After the initial reply to your report, the security team will23+endeavor to keep you informed of the progress towards a fix and full24+announcement, and may ask for additional information or guidance.25+26+Report security bugs in third-party modules to the person or team maintaining27+the module. You can also report a vulnerability through the28+[Node Security Project](https://nodesecurity.io/report).29+30+## Disclosure Policy31+32+When the security team receives a security bug report, they will assign it to a33+primary handler. This person will coordinate the fix and release process,34+involving the following steps:35+36+ * Confirm the problem and determine the affected versions.37+ * Audit code to find any potential similar problems.38+ * Prepare fixes for all releases still under maintenance. These fixes will be39+ released as fast as possible to npm.40+41+## Comments on this Policy42+43+If you have suggestions on how this process could be improved please submit a44+pull request.