Skip to content
Myr

Merge branch 'master' into 5.0

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

authored by ctcpip · committed by ctcpip · parents ee40a88, 2ec589c · Browse files · 17 files+365 added−106 removed
This commit

State

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

Diff stats

17 files+365 added−106 removed

  • tests:+60 added−16 removed
  • other:+305 added−90 removed

17 files+365 added−106 removed

modified:.github/workflows/ci.yml+39 added-33 removed
1name: ci23on:4- pull_request5- push4 push:5 branches:6 - master7 - develop8 - '4.x'9 - '5.x'10 paths-ignore:11 - '*.md'12 pull_request:13 paths-ignore:14 - '*.md'1516# Cancel in progress workflows17# in the scenario where we already had a run going for that PR/branch/tag but then triggered a new run18concurrency:19 group: "${{ github.workflow }} ✨ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"20 cancel-in-progress: true2122jobs:23 test:24 runs-on: ubuntu-latest25 strategy:
18 unmodified lines
44 - Node.js 18.x45 - Node.js 19.x46 - Node.js 20.x47 - Node.js 21.x48 - Node.js 22.x4950 include:35 - name: Node.js 4.036 node-version: "4.0"37 npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.23851 - name: Node.js 4.x40 node-version: "4.9"52 node-version: "4"53 npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.25455 - name: Node.js 5.x44 node-version: "5.12"56 node-version: "5"57 npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.25859 - name: Node.js 6.x48 node-version: "6.17"60 node-version: "6"61 npm-i: mocha@6.2.2 nyc@14.1.1 supertest@3.4.26263 - name: Node.js 7.x52 node-version: "7.10"64 node-version: "7"65 npm-i: mocha@6.2.2 nyc@14.1.1 supertest@6.1.66667 - name: Node.js 8.x56 node-version: "8.17"68 node-version: "8"69 npm-i: mocha@7.2.0 nyc@14.1.17071 - name: Node.js 9.x60 node-version: "9.11"72 node-version: "9"73 npm-i: mocha@7.2.0 nyc@14.1.17475 - name: Node.js 10.x64 node-version: "10.24"76 node-version: "10"77 npm-i: mocha@8.4.07879 - name: Node.js 11.x68 node-version: "11.15"80 node-version: "11"81 npm-i: mocha@8.4.08283 - name: Node.js 12.x72 node-version: "12.22"84 node-version: "12"85 npm-i: mocha@9.2.28687 - name: Node.js 13.x76 node-version: "13.14"88 node-version: "13"89 npm-i: mocha@9.2.29091 - name: Node.js 14.x80 node-version: "14.20"92 node-version: "14"9394 - name: Node.js 15.x83 node-version: "15.14"95 node-version: "15"9697 - name: Node.js 16.x86 node-version: "16.20"98 node-version: "16"99100 - name: Node.js 17.x89 node-version: "17.9"101 node-version: "17"102103 - name: Node.js 18.x92 node-version: "18.19"104 node-version: "18"105106 - name: Node.js 19.x95 node-version: "19.9"107 node-version: "19"108109 - name: Node.js 20.x98 node-version: "20.11"110 node-version: "20"111112 - name: Node.js 21.x101 node-version: "21.6"113 node-version: "21"114115 - name: Node.js 22.x116 node-version: "22"117118 steps:119 - uses: actions/checkout@v4120121 - name: Install Node.js ${{ matrix.node-version }}
1 unmodified line
123 run: |124 nvm install --default ${{ matrix.node-version }}125 dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"126112 - name: Configure npm113 run: |114 npm config set loglevel error115 if [[ "$(npm config get package-lock)" == "true" ]]; then116 npm config set package-lock false117 else118 npm config set shrinkwrap false119 fi120127 - name: Install npm module(s) ${{ matrix.npm-i }}128 run: npm install --save-dev ${{ matrix.npm-i }}129 if: matrix.npm-i != ''130
74 unmodified lines
added:.github/workflows/codeql.yml+66 added
modified:lib/response.js+9 added-15 removed
48 unmodified lines
4950module.exports = res5152/**53 * Module variables.54 * @private55 */5657var schemaAndHostRegExp = /^(?:[a-zA-Z][a-zA-Z0-9+.-]*:)?\/\/[^\\\/\?]+/;5859/**53 * Set status `code`.54 *55 * @param {Number} code56 * @return {ServerResponse}
632 unmodified lines
689 * @public690 */691692res.clearCookie = function clearCookie(name, options) {693 if (options) {694 if (options.maxAge) {695 deprecate('res.clearCookie: Passing "options.maxAge" is deprecated. In v5.0.0 of Express, this option will be ignored, as res.clearCookie will automatically set cookies to expire immediately. Please update your code to omit this option.');696 }697 if (options.expires) {698 deprecate('res.clearCookie: Passing "options.expires" is deprecated. In v5.0.0 of Express, this option will be ignored, as res.clearCookie will automatically set cookies to expire immediately. Please update your code to omit this option.');699 }700 }701 var opts = merge({ expires: new Date(1), path: '/' }, options);702703 return this.cookie(name, '', opts);704};
83 unmodified lines
788 } else {789 loc = String(url);790 }791791 var m = schemaAndHostRegExp.exec(loc);792 var pos = m ? m[0].length + 1 : 0;793794 // Only encode after host to avoid invalid encoding which can introduce795 // vulnerabilities (e.g. `\\` to `%5C`).796 loc = loc.slice(0, pos) + encodeUrl(loc.slice(pos));797798 return this.set('Location', loc);792 return this.set('Location', encodeUrl(loc));793};794795/**796 * Redirect to the given `url` with optional response `status`
239 unmodified lines
modified:test/support/utils.js+14 added
modified:test/app.router.js+4 added
5 unmodified lines
6 , assert = require('assert')7 , methods = require('methods');89var describePromises = global.Promise ? describe : describe.skip10var shouldSkipQuery = require('./support/utils').shouldSkipQuery1112describe('app.router', function(){13 it('should restore req.params after leaving router', function(done){14 var app = express();
26 unmodified lines
41 methods.forEach(function(method){42 if (method === 'connect') return;4344 it('should include ' + method.toUpperCase(), function(done){45 if (method === 'query' && shouldSkipQuery(process.versions.node)) {46 this.skip()47 }48 var app = express();4950 app[method]('/foo', function(req, res){51 res.send(method)
1091 unmodified lines
modified:test/res.clearCookie.js+32 added
modified:test/res.location.js+5 added-16 removed
102 unmodified lines
103 .expect(200, done)104 })105 })106107 it('should encode data uri', function (done) {107 it('should encode data uri1', function (done) {108 var app = express()109 app.use(function (req, res) {110 res.location('data:text/javascript,export default () => { }').end();111 });
3 unmodified lines
115 .expect('Location', 'data:text/javascript,export%20default%20()%20=%3E%20%7B%20%7D')116 .expect(200, done)117 })118119 it('should encode data uri', function (done) {119 it('should encode data uri2', function (done) {120 var app = express()121 app.use(function (req, res) {122 res.location('data:text/javascript,export default () => { }').end();123 });
180 unmodified lines
304 done305 );306 });307308 it('should percent encode backslashes in the path', function (done) {308 it('should keep backslashes in the path', function (done) {309 var app = createRedirectServerForDomain('google.com');310 testRequestedRedirect(311 app,312 'https://google.com/foo\\bar\\baz',313 'https://google.com/foo%5Cbar%5Cbaz',313 'https://google.com/foo\\bar\\baz',314 'google.com',315 done316 );317 });318319 it('should encode backslashes in the path after the first backslash that triggered path parsing', function (done) {320 var app = createRedirectServerForDomain('google.com');321 testRequestedRedirect(322 app,323 'https://google.com\\@app\\l\\e.com',324 'https://google.com\\@app%5Cl%5Ce.com',325 'google.com',326 done327 );328 });329319 it('should escape header splitting for old node versions', function (done) {320 var app = createRedirectServerForDomain('google.com');321 testRequestedRedirect(322 app,
41 unmodified lines
364 var app = createRedirectServerForDomain('');365 testRequestedRedirect(366 app,367 'file:///etc\\passwd',379 'file:///etc%5Cpasswd',368 'file:///etc\\passwd',369 '',370 done371 );372 });
2 unmodified lines
modified:test/res.send.js+5 added
5 unmodified lines
6var methods = require('methods');7var request = require('supertest');8var utils = require('./support/utils');910var shouldSkipQuery = require('./support/utils').shouldSkipQuery1112describe('res', function(){13 describe('.send()', function(){14 it('should set body to ""', function(done){15 var app = express();
349 unmodified lines
365 methods.forEach(function (method) {366 if (method === 'connect') return;367368 it('should send ETag in response to ' + method.toUpperCase() + ' request', function (done) {369 if (method === 'query' && shouldSkipQuery(process.versions.node)) {370 this.skip()371 }372 var app = express();373374 app[method]('/', function (req, res) {375 res.send('kajdslfkasdf');
181 unmodified lines
added:.npmrc+1 added
1package-lock=false
modified:appveyor.yml+1 added
16 unmodified lines
17 - nodejs_version: "18.19"18 - nodejs_version: "19.9"19 - nodejs_version: "20.11"20 - nodejs_version: "21.6"21 - nodejs_version: "22.0"22cache:23 - node_modules24install:25 # Install Node.js
82 unmodified lines
modified:Code-Of-Conduct.md+1 added-1 removed
125 unmodified lines
126project community.127128## Attribution129130This Code of Conduct is adapted from the [Contributor Covenant, version 2.0](cc-20-doc).130This Code of Conduct is adapted from the [Contributor Covenant, version 2.0][cc-20-doc].131132Community Impact Guidelines were inspired by133[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).134
5 unmodified lines
modified:Contributing.md+67 added-34 removed
61 unmodified lines
6263Anyone can become a triager! Read more about the process of being a triager in64[the triage process document](Triager-Guide.md).6566[Open an issue in `expressjs/express` repo](https://github.com/expressjs/express/issues/new)67to request the triage role. State that you have read and agree to the68[Code of Conduct](Code-Of-Conduct.md) and details of the role.66Currently, any existing [organization member](https://github.com/orgs/expressjs/people) can nominate67a new triager. If you are interested in becoming a triager, our best advice is to actively participate68in the community by helping triaging issues and pull requests. As well we recommend69to engage in other community activities like attending the TC meetings, and participating in the Slack70discussions.7170Here is an example issue content you can copy and paste:72You can also reach out to any of the [organization members](https://github.com/orgs/expressjs/people)73if you have questions or need guidance.7472```73Title: Request triager role for <your GitHub username>7475I have read and understood the project's Code of Conduct.76I also have read and understood the process and best practices around Express triaging.7778I request for a triager role for the following GitHub organizations:7980jshttp81pillarjs82express83```8485Once you have opened your issue, a member of the TC will add you to the `triage` team in86the organizations requested. They will then close the issue.8788Happy triaging!8975## Becoming a Committer7677All contributors who land a non-trivial contribution should be on-boarded in a timely manner,78and added as a committer, and be given write access to the repository.
59 unmodified lines
138the project, their GitHub handle and npm username (if different). The PR will require139at least 2 approvals from TC members and 2 weeks hold time to allow for comment and/or140dissent. When the PR is merged, a TC member will add them to the proper GitHub/npm groups.141157### Current Project Captains142### Active Projects and Captains143159- `expressjs/express`: @wesleytodd144- `expressjs/badgeboard`: @wesleytodd145- `expressjs/basic-auth-connect`: N/A146- `expressjs/body-parser`: @wesleytodd, @jonchurch147- `expressjs/compression`: N/A148- `expressjs/connect-multiparty`: N/A149- `expressjs/cookie-parser`: @wesleytodd, @UlisesGascon150- `expressjs/cookie-session`: N/A151- `expressjs/cors`: @jonchurch152- `expressjs/discussions`: @wesleytodd161- `expressjs/expressjs.com`: @crandmck162- `expressjs/body-parser`: @wesleytodd163- `expressjs/multer`: @LinusU164- `expressjs/cookie-parser`: @wesleytodd153- `expressjs/errorhandler`: N/A154- `expressjs/express-paginate`: N/A155- `expressjs/express`: @wesleytodd156- `expressjs/expressjs.com`: @crandmck, @jonchurch157- `expressjs/flash`: N/A158- `expressjs/generator`: @wesleytodd159- `expressjs/method-override`: N/A160- `expressjs/morgan`: @jonchurch161- `expressjs/multer`: @LinusU162- `expressjs/response-time`: @blakeembrey163- `expressjs/serve-favicon`: N/A164- `expressjs/serve-index`: N/A165- `expressjs/serve-static`: N/A166- `expressjs/session`: N/A167- `expressjs/statusboard`: @wesleytodd167- `pillarjs/path-to-regexp`: @blakeembrey168- `pillarjs/router`: @dougwilson, @wesleytodd169- `pillarjs/finalhandler`: @wesleytodd170- `pillarjs/request`: @wesleytodd171- `jshttp/http-errors`: @wesleytodd168- `expressjs/timeout`: N/A169- `expressjs/vhost`: N/A170- `jshttp/accepts`: @blakeembrey171- `jshttp/basic-auth`: @blakeembrey172- `jshttp/compressible`: @blakeembrey173- `jshttp/content-disposition`: @blakeembrey174- `jshttp/content-type`: @blakeembrey175- `jshttp/cookie`: @wesleytodd176- `jshttp/etag`: @blakeembrey177- `jshttp/forwarded`: @blakeembrey178- `jshttp/fresh`: @blakeembrey179- `jshttp/http-assert`: @wesleytodd, @jonchurch180- `jshttp/http-errors`: @wesleytodd, @jonchurch181- `jshttp/media-typer`: @blakeembrey182- `jshttp/methods`: @blakeembrey183- `jshttp/mime-db`: @blakeembrey, @UlisesGascon 184- `jshttp/mime-types`: @blakeembrey, @UlisesGascon 185- `jshttp/negotiator`: @blakeembrey186- `jshttp/on-finished`: @wesleytodd174- `jshttp/forwarded`: @wesleytodd187- `jshttp/on-headers`: @blakeembrey188- `jshttp/proxy-addr`: @wesleytodd189- `jshttp/range-parser`: @blakeembrey190- `jshttp/statuses`: @blakeembrey191- `jshttp/type-is`: @blakeembrey192- `jshttp/vary`: @blakeembrey193- `pillarjs/cookies`: @blakeembrey194- `pillarjs/csrf`: N/A195- `pillarjs/encodeurl`: @blakeembrey196- `pillarjs/finalhandler`: @wesleytodd197- `pillarjs/hbs`: N/A198- `pillarjs/multiparty`: @blakeembrey199- `pillarjs/parseurl`: @blakeembrey200- `pillarjs/path-to-regexp`: @blakeembrey201- `pillarjs/request`: @wesleytodd202- `pillarjs/resolve-path`: @blakeembrey203- `pillarjs/router`: @blakeembrey204- `pillarjs/send`: @blakeembrey205- `pillarjs/understanding-csrf`: N/A206207### Current Initiative Captains208209- Triage team [ref](https://github.com/expressjs/discussions/issues/227): @UlisesGascon
modified:History.md+8 added
165 unmodified lines
166 - `req.query` is now a getter instead of a plain property167 * add:168 - `app.router` is a reference to the base router169170unreleased171==========172173 * deps: encodeurl@~2.0.0174 - Removes encoding of `\`, `|`, and `^` to align better with URL spec175 * Deprecate passing `options.maxAge` and `options.expires` to `res.clearCookie`176 - Will be ignored in v5, clearCookie will set a cookie with an expires in the past to instruct clients to delete the cookie1771784.19.2 / 2024-03-25179==========180181 * Improved fix for open redirect allow list bypass
3611 unmodified lines
modified:package.json+1 added-1 removed
35 unmodified lines
36 "cookie": "0.6.0",37 "cookie-signature": "1.0.6",38 "debug": "3.1.0",39 "depd": "2.0.0",40 "encodeurl": "~1.0.2",40 "encodeurl": "~2.0.0",41 "escape-html": "~1.0.3",42 "etag": "~1.8.1",43 "finalhandler": "1.2.0",44 "fresh": "0.5.2",
57 unmodified lines
modified:Readme.md+95 added-6 removed
1[![Express Logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](http://expressjs.com/)23 Fast, unopinionated, minimalist web framework for [Node.js](http://nodejs.org).3**Fast, unopinionated, minimalist web framework for [Node.js](http://nodejs.org).**45 [![NPM Version][npm-version-image]][npm-url]6 [![NPM Install Size][npm-install-size-image]][npm-install-size-url]7 [![NPM Downloads][npm-downloads-image]][npm-downloads-url]5**This project has a [Code of Conduct][].**67## Table of contents89* [Installation](#Installation)10* [Features](#Features)11* [Docs & Community](#docs--community)12* [Quick Start](#Quick-Start)13* [Running Tests](#Running-Tests)14* [Philosophy](#Philosophy)15* [Examples](#Examples)16* [Contributing to Express](#Contributing)17* [TC (Technical Committee)](#tc-technical-committee)18* [Triagers](#triagers)19* [License](#license)202122[![NPM Version][npm-version-image]][npm-url]23[![NPM Install Size][npm-install-size-image]][npm-install-size-url]24[![NPM Downloads][npm-downloads-image]][npm-downloads-url]2526```js27const express = require('express')28const app = express()29
130 unmodified lines
160## People161162The original author of Express is [TJ Holowaychuk](https://github.com/tj)163147The current lead maintainer is [Douglas Christopher Wilson](https://github.com/dougwilson)148164[List of all contributors](https://github.com/expressjs/express/graphs/contributors)165166### TC (Technical Committee)167168* [UlisesGascon](https://github.com/UlisesGascon) - **Ulises Gascón** (he/him)169* [jonchurch](https://github.com/jonchurch) - **Jon Church**170* [wesleytodd](https://github.com/wesleytodd) - **Wes Todd**171* [LinusU](https://github.com/LinusU) - **Linus Unnebäck**172* [blakeembrey](https://github.com/blakeembrey) - **Blake Embrey**173* [sheplu](https://github.com/sheplu) - **Jean Burellier**174* [crandmck](https://github.com/crandmck) - **Rand McKinney**175* [ctcpip](https://github.com/ctcpip) - **Chris de Almeida**176177<details>178<summary>TC emeriti members</summary>179180#### TC emeriti members181182 * [dougwilson](https://github.com/dougwilson) - **Douglas Wilson**183 * [hacksparrow](https://github.com/hacksparrow) - **Hage Yaapa**184 * [jonathanong](https://github.com/jonathanong) - **jongleberry**185 * [niftylettuce](https://github.com/niftylettuce) - **niftylettuce**186 * [troygoode](https://github.com/troygoode) - **Troy Goode**187</details>188189190### Triagers191192* [aravindvnair99](https://github.com/aravindvnair99) - **Aravind Nair**193* [carpasse](https://github.com/carpasse) - **Carlos Serrano**194* [CBID2](https://github.com/CBID2) - **Christine Belzie**195* [enyoghasim](https://github.com/enyoghasim) - **David Enyoghasim**196* [UlisesGascon](https://github.com/UlisesGascon) - **Ulises Gascón** (he/him)197* [mertcanaltin](https://github.com/mertcanaltin) - **Mert Can Altin**198* [0ss](https://github.com/0ss) - **Salah**199* [import-brain](https://github.com/import-brain) - **Eric Cheng** (he/him)200* [3imed-jaberi](https://github.com/3imed-jaberi) - **Imed Jaberi**201* [dakshkhetan](https://github.com/dakshkhetan) - **Daksh Khetan** (he/him)202* [lucasraziel](https://github.com/lucasraziel) - **Lucas Soares Do Rego**203* [Sushmeet](https://github.com/Sushmeet) - **Sushmeet Sunger**204205<details>206<summary>Triagers emeriti members</summary>207208#### Emeritus Triagers209210 * [AuggieH](https://github.com/AuggieH) - **Auggie Hudak**211 * [G-Rath](https://github.com/G-Rath) - **Gareth Jones**212 * [MohammadXroid](https://github.com/MohammadXroid) - **Mohammad Ayashi**213 * [NawafSwe](https://github.com/NawafSwe) - **Nawaf Alsharqi**214 * [NotMoni](https://github.com/NotMoni) - **Moni**215 * [VigneshMurugan](https://github.com/VigneshMurugan) - **Vignesh Murugan**216 * [davidmashe](https://github.com/davidmashe) - **David Ashe**217 * [digitaIfabric](https://github.com/digitaIfabric) - **David**218 * [e-l-i-s-e](https://github.com/e-l-i-s-e) - **Elise Bonner**219 * [fed135](https://github.com/fed135) - **Frederic Charette**220 * [firmanJS](https://github.com/firmanJS) - **Firman Abdul Hakim**221 * [getspooky](https://github.com/getspooky) - **Yasser Ameur**222 * [ghinks](https://github.com/ghinks) - **Glenn**223 * [ghousemohamed](https://github.com/ghousemohamed) - **Ghouse Mohamed**224 * [gireeshpunathil](https://github.com/gireeshpunathil) - **Gireesh Punathil**225 * [jake32321](https://github.com/jake32321) - **Jake Reed**226 * [jonchurch](https://github.com/jonchurch) - **Jon Church**227 * [lekanikotun](https://github.com/lekanikotun) - **Troy Goode**228 * [marsonya](https://github.com/marsonya) - **Lekan Ikotun**229 * [mastermatt](https://github.com/mastermatt) - **Matt R. Wilson**230 * [maxakuru](https://github.com/maxakuru) - **Max Edell**231 * [mlrawlings](https://github.com/mlrawlings) - **Michael Rawlings**232 * [rodion-arr](https://github.com/rodion-arr) - **Rodion Abdurakhimov**233 * [sheplu](https://github.com/sheplu) - **Jean Burellier**234 * [tarunyadav1](https://github.com/tarunyadav1) - **Tarun yadav**235 * [tunniclm](https://github.com/tunniclm) - **Mike Tunnicliffe**236</details>237238239## License240241 [MIT](LICENSE)242
8 unmodified lines
251[npm-install-size-image]: https://badgen.net/packagephobia/install/express252[npm-install-size-url]: https://packagephobia.com/result?p=express253[npm-url]: https://npmjs.org/package/express254[npm-version-image]: https://badgen.net/npm/v/express255[Code of Conduct]: https://github.com/expressjs/express/blob/master/Code-Of-Conduct.md
modified:Release-Process.md+7 added
75 unmodified lines
76 pull request the content of the release may have be discussed in an issue.77- This branch contains the commits accepted so far that implement the proposal78 in the tracking pull request.7980### Pre-release Versions8182Alpha and Beta releases are made from a proposal branch. The version number should be83incremented to the next minor version with a `-beta` or `-alpha` suffix.84For example, if the next beta release is `5.0.1`, the beta release would be `5.0.1-beta.0`.85The pre-releases are unstable and not suitable for production use.8687### Patch flow8889In the patch flow, simple changes are committed to the release branch which90acts as an ever-present branch for the next patch release of the associated
109 unmodified lines
modified:Security.md+10 added
27 unmodified lines
2829Report security bugs in third-party modules to the person or team maintaining30the module.3132## Pre-release Versions3334Alpha and Beta releases are unstable and **not suitable for production use**.35Vulnerabilities found in pre-releases should be reported according to the [Reporting a Bug](#reporting-a-bug) section.36Due to the unstable nature of the branch it is not guaranteed that any fixes will be released in the next pre-release.3738## Disclosure Policy3940When the security team receives a security bug report, they will assign it to a41primary handler. This person will coordinate the fix and release process,
3 unmodified lines
45 * Audit code to find any potential similar problems.46 * Prepare fixes for all releases still under maintenance. These fixes will be47 released as fast as possible to npm.4849## The Express Threat Model5051We are currently working on a new version of the security model, the most updated version can be found [here](https://github.com/expressjs/security-wg/blob/main/docs/ThreatModel.md)5253## Comments on this Policy5455If you have suggestions on how this process could be improved please submit a56pull request.