Merge tag '4.20.0' into 5.0
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Wes Todd · committed by Wes Todd · parents 63992bb, 21df421 · Browse files · 9 files·+81 added−15 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
9 files+81 added−15 removed
- tests:+51 added−7 removed
- other:+30 added−8 removed
Provenance
- Commit
e5feb9f- Tree
5dfc2eb- Author
Wes Todd <wes@wesleytodd.com>- Committer
Wes Todd <wes@wesleytodd.com>- Parent 1
63992bb- Parent 2
21df421
9 files changed+81 added−15 removed
modified:lib/response.js+1 added-1 removed
835 unmodified lines836 },837 838 html: function(){839 var u = escapeHtml(address);840- body = '<p>' + statuses.message[status] + '. Redirecting to <a href="' + u + '">' + u + '</a></p>'840+ body = '<p>' + statuses.message[status] + '. Redirecting to ' + u + '</p>'841 },842 843 default: function(){844 body = '';196 unmodified linesmodified:test/app.router.js+26 added
192 unmodified lines193 .get('/user/10/edit')194 .expect('editing user 10', done);195 })196 197+ if (supportsRegexp('(?<foo>.*)')) {198+ it('should populate req.params with named captures', function(done){199+ var app = express();200+ var re = new RegExp('^/user/(?<userId>[0-9]+)/(view|edit)?$');201+202+ app.get(re, function(req, res){203+ var id = req.params.userId204+ , op = req.params[0];205+ res.end(op + 'ing user ' + id);206+ });207+208+ request(app)209+ .get('/user/10/edit')210+ .expect('editing user 10', done);211+ })212+ }213+214 it('should ensure regexp matches path prefix', function (done) {215 var app = express()216 var p = []217 938 unmodified lines1156 var app = express();1157 assert.strictEqual(app.get('/', function () {}), app)1158 })1159 })1160+1161+function supportsRegexp(source) {1162+ try {1163+ new RegExp(source)1164+ return true1165+ } catch (e) {1166+ return false1167+ }1168+}modified:test/express.static.js+2 added-2 removed
484 unmodified lines485 it('should include HTML link', function (done) {486 request(this.app)487 .get('/users')488 .expect('Location', '/users/')489- .expect(301, /<a href="\/users\/">/, done)489+ .expect(301, /\/users\//, done)490 })491 492 it('should redirect directories with query string', function (done) {493 request(this.app)13 unmodified lines507 request(this.app)508 .get('/snow')509 .expect('Location', '/snow%20%E2%98%83/')510 .expect('Content-Type', /html/)511- .expect(301, />Redirecting to <a href="\/snow%20%E2%98%83\/">\/snow%20%E2%98%83\/<\/a></, done)511+ .expect(301, />Redirecting to \/snow%20%E2%98%83\/</, done)512 })513 514 it('should respond with default Content-Security-Policy', function (done) {515 request(this.app)299 unmodified linesmodified:test/express.urlencoded.js+2 added-2 removed
184 unmodified lines185 186 it('should parse deep object', function (done) {187 var str = 'foo'188 189- for (var i = 0; i < 500; i++) {189+ for (var i = 0; i < 32; i++) {190 str += '[p]'191 }192 193 str += '=bar'9 unmodified lines203 204 var depth = 0205 var ref = obj.foo206 while ((ref = ref.p)) { depth++ }207- assert.strictEqual(depth, 500)207+ assert.strictEqual(depth, 32)208 })209 .expect(200, done)210 })211 })628 unmodified linesmodified:test/res.redirect.js+21 added-3 removed
89 unmodified lines90 .get('/')91 .set('Accept', 'text/html')92 .expect('Content-Type', /html/)93 .expect('Location', 'http://google.com')94- .expect(302, '<p>Found. Redirecting to <a href="http://google.com">http://google.com</a></p>', done)94+ .expect(302, '<p>Found. Redirecting to http://google.com</p>', done)95 })96 97 it('should escape the url', function(done){98 var app = express();7 unmodified lines106 .set('Host', 'http://example.com')107 .set('Accept', 'text/html')108 .expect('Content-Type', /html/)109 .expect('Location', '%3Cla\'me%3E')110- .expect(302, '<p>Found. Redirecting to <a href="%3Cla'me%3E">%3Cla'me%3E</a></p>', done)110+ .expect(302, '<p>Found. Redirecting to %3Cla'me%3E</p>', done)111 })112 113+ it('should not render evil javascript links in anchor href (prevent XSS)', function(done){114+ var app = express();115+ var xss = 'javascript:eval(document.body.innerHTML=`<p>XSS</p>`);';116+ var encodedXss = 'javascript:eval(document.body.innerHTML=%60%3Cp%3EXSS%3C/p%3E%60);';117+118+ app.use(function(req, res){119+ res.redirect(xss);120+ });121+122+ request(app)123+ .get('/')124+ .set('Host', 'http://example.com')125+ .set('Accept', 'text/html')126+ .expect('Content-Type', /html/)127+ .expect('Location', encodedXss)128+ .expect(302, '<p>Found. Redirecting to ' + encodedXss +'</p>', done);129+ });130+131 it('should include the redirect type', function(done){132 var app = express();133 134 app.use(function(req, res){4 unmodified lines139 .get('/')140 .set('Accept', 'text/html')141 .expect('Content-Type', /html/)142 .expect('Location', 'http://google.com')125- .expect(301, '<p>Moved Permanently. Redirecting to <a href="http://google.com">http://google.com</a></p>', done);143+ .expect(301, '<p>Moved Permanently. Redirecting to http://google.com</p>', done);144 })145 })146 147 describe('when accepting text', function(){67 unmodified linesmodified:History.md+12 added-2 removed
174 unmodified lines175 - `req.query` is now a getter instead of a plain property176 * add:177 - `app.router` is a reference to the base router178 179-unreleased179+4.20.0 / 2024-09-10180 ==========181-181+ * deps: serve-static@0.16.0182+ * Remove link renderization in html while redirecting183+ * deps: send@0.19.0184+ * Remove link renderization in html while redirecting185+ * deps: body-parser@0.6.0186+ * add `depth` option to customize the depth level in the parser187+ * IMPORTANT: The default `depth` level for parsing URL-encoded data is now `32` (previously was `Infinity`)188+ * Remove link renderization in html while using `res.redirect`189+ * deps: path-to-regexp@0.1.10190+ - Adds support for named matching groups in the routes using a regex191+ - Adds backtracking protection to parameters without regexes defined192 * deps: encodeurl@~2.0.0193 - Removes encoding of `\`, `|`, and `^` to align better with URL spec194 * Deprecate passing `options.maxAge` and `options.expires` to `res.clearCookie`195 - Will be ignored in v5, clearCookie will set a cookie with an expires in the past to instruct clients to delete the cookie3616 unmodified linesmodified:package.json+5 added-1 removed
12345678910111232 unmodified lines4546474845495051525351 unmodified lines{ "name": "express", "description": "Fast, unopinionated, minimalist web framework",<<<<<<< HEAD "version": "5.0.0-beta.3",======= "version": "4.20.0",>>>>>>> master "author": "TJ Holowaychuk <tj@vision-media.ca>", "contributors": [ "Aaron Heckmann <aaron.heckmann+github@gmail.com>", "Ciaran Jessup <ciaranj@gmail.com>",32 unmodified lines "etag": "~1.8.1", "finalhandler": "1.2.0", "fresh": "0.5.2", "http-errors": "2.0.0", "merge-descriptors": "1.0.1", "merge-descriptors": "1.0.3", "methods": "~1.1.2", "mime-types": "~2.1.34", "on-finished": "2.4.1", "once": "1.4.0",51 unmodified linesmodified:Readme.md+3 added-2 removed
200 unmodified lines201 * [import-brain](https://github.com/import-brain) - **Eric Cheng** (he/him)202 * [3imed-jaberi](https://github.com/3imed-jaberi) - **Imed Jaberi**203 * [dakshkhetan](https://github.com/dakshkhetan) - **Daksh Khetan** (he/him)204 * [lucasraziel](https://github.com/lucasraziel) - **Lucas Soares Do Rego**205+* [IamLizu](https://github.com/IamLizu) - **S M Mahmudul Hasan** (he/him)206 * [Sushmeet](https://github.com/Sushmeet) - **Sushmeet Sunger**207 208 <details>209 <summary>Triagers emeriti members</summary>44 unmodified lines254 [npm-install-size-image]: https://badgen.net/packagephobia/install/express255 [npm-install-size-url]: https://packagephobia.com/result?p=express256 [npm-url]: https://npmjs.org/package/express257 [npm-version-image]: https://badgen.net/npm/v/express257-[ossf-scorecard-badge]: https://api.securityscorecards.dev/projects/github.com/expressjs/express/badge258-[ossf-scorecard-visualizer]: https://kooltheba.github.io/openssf-scorecard-api-visualizer/#/projects/github.com/expressjs/express258+[ossf-scorecard-badge]: https://api.scorecard.dev/projects/github.com/expressjs/express/badge259+[ossf-scorecard-visualizer]: https://ossf.github.io/scorecard-visualizer/#/projects/github.com/expressjs/express260 [Code of Conduct]: https://github.com/expressjs/express/blob/master/Code-Of-Conduct.mdmodified:Triager-Guide.md+9 added-2 removed
7 unmodified lines8 classification:9 10 * `needs triage`: This can be kept if the triager is unsure which next steps to take11 * `awaiting more info`: If more info has been requested from the author, apply this label.12-* `question`: User questions that do not appear to be bugs or enhancements.13-* `discuss`: Topics for discussion. Might end in an `enhancement` or `question` label.12 * `bug`: Issues that present a reasonable conviction there is a reproducible bug.13 * `enhancement`: Issues that are found to be a reasonable candidate feature additions.14 15+If the issue is a question or discussion, it should be moved to GitHub Discussions.16+17+### Moving Discussions and Questions to GitHub Discussions18+19+For issues labeled with `question` or `discuss`, it is recommended to move them to GitHub Discussions instead:20+21+* **Questions**: User questions that do not appear to be bugs or enhancements should be moved to GitHub Discussions.22+* **Discussions**: Topics for discussion should be moved to GitHub Discussions. If the discussion leads to a new feature or bug identification, it can be moved back to Issues.23+24 In all cases, issues may be closed by maintainers if they don't receive a timely response when25 further information is sought, or when additional questions are asked.26 27 ## Approaches and Best Practices for getting into triage contributions43 unmodified lines