Merge branch 'master' of github.com:visionmedia/express
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by TJ Holowaychuk · committed by TJ Holowaychuk · parents 9cbcf23, 36e42db · Browse files · 5 files·+44 added−35 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+44 added−35 removed
- tests:+9 added−9 removed
- other:+35 added−26 removed
Provenance
- Commit
bd8b9f5- Tree
3b51c6c- Author
TJ Holowaychuk <tj@vision-media.ca>- Committer
TJ Holowaychuk <tj@vision-media.ca>- Parent 1
9cbcf23- Parent 2
36e42db
5 files changed+44 added−35 removed
modified:lib/response.js+2 added-2 removed
240 unmodified lines241 if (callback) {242 if (Array.isArray(callback)) callback = callback[0];243 this.set('Content-Type', 'text/javascript');244 var cb = callback.replace(/[^\[\]\w$.]/g, '');245- body = cb + ' && ' + cb + '(' + body + ');';245+ body = 'typeof ' + cb + ' === \'function\' && ' + cb + '(' + body + ');';246 }247 248 return this.send(body);249 };499 unmodified lines749 }750 751 var vary = this.get('Vary');752 753- // append 753+ // append754 if (vary) {755 vary = vary.split(/ *, */);756 if (!~vary.indexOf(field)) vary.push(field);757 this.set('Vary', vary.join(', '));47 unmodified linesmodified:test/res.jsonp.js+9 added-9 removed
14 unmodified lines15 request(app)16 .get('/?callback=something')17 .end(function(err, res){18 res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8');19- res.text.should.equal('something && something({"count":1});');19+ res.text.should.equal('typeof something === \'function\' && something({"count":1});');20 done();21 })22 })23 7 unmodified lines31 request(app)32 .get('/?callback=something&callback=somethingelse')33 .end(function(err, res){34 res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8');35- res.text.should.equal('something && something({"count":1});');35+ res.text.should.equal('typeof something === \'function\' && something({"count":1});');36 done();37 })38 })39 9 unmodified lines49 request(app)50 .get('/?clb=something')51 .end(function(err, res){52 res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8');53- res.text.should.equal('something && something({"count":1});');53+ res.text.should.equal('typeof something === \'function\' && something({"count":1});');54 done();55 })56- }) 56+ })57 58 it('should allow []', function(done){59 var app = express();60 4 unmodified lines65 request(app)66 .get('/?callback=callbacks[123]')67 .end(function(err, res){68 res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8');69- res.text.should.equal('callbacks[123] && callbacks[123]({"count":1});');69+ res.text.should.equal('typeof callbacks[123] === \'function\' && callbacks[123]({"count":1});');70 done();71 })72 })73 7 unmodified lines81 request(app)82 .get('/?callback=foo;bar()')83 .end(function(err, res){84 res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8');85- res.text.should.equal('foobar && foobar({});');85+ res.text.should.equal('typeof foobar === \'function\' && foobar({});');86 done();87 })88 })89 7 unmodified lines97 request(app)98 .get('/?callback=foo')99 .end(function(err, res){100 res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8');101- res.text.should.equal('foo && foo({"str":"\\u2028 \\u2029 woot"});');101+ res.text.should.equal('typeof foo === \'function\' && foo({"str":"\\u2028 \\u2029 woot"});');102 done();103 });104 });105 31 unmodified lines137 done();138 })139 })140 })141- 141+142 describe('when given an object', function(){143 it('should respond with json', function(done){144 var app = express();145 64 unmodified lines210 });211 })212 })213 })214- 214+215 describe('.json(status, object)', function(){216 it('should respond with json and set the .statusCode', function(done){217 var app = express();218 34 unmodified linesmodified:History.md+30 added-22 removed
1+3.4.1 / 2013-10-152+==================3+ * update connect4+ * update commander5+ * jsonp: check if callback is a function6+ * router: wrap encodeURIComponent in a try/catch #1735 (@lxe)7+ * res.format: now includes chraset @1747 (@sorribas)8+ * res.links: allow multiple calls @1746 (@sorribas)9 2-3.4.0 / 2013-09-07 10+3.4.0 / 2013-09-0711 ==================12 13 * add res.vary(). Closes #168214 * update connect15 8-3.3.8 / 2013-09-02 16+3.3.8 / 2013-09-0217 ==================18 19 * update connect20 13-3.3.7 / 2013-08-28 21+3.3.7 / 2013-08-2822 ==================23 24 * update connect25 18-3.3.6 / 2013-08-27 26+3.3.6 / 2013-08-2727 ==================28 29 * Revert "remove charset from json responses. Closes #1631" (causes issues in some clients)30 * add: req.accepts take an argument list31 24-3.3.4 / 2013-07-08 32+3.3.4 / 2013-07-0833 ==================34 35 * update send and connect36 29-3.3.3 / 2013-07-04 37+3.3.3 / 2013-07-0438 ==================39 40 * update connect41 34-3.3.2 / 2013-07-03 42+3.3.2 / 2013-07-0343 ==================44 45 * update connect46 * update send47 * remove .version export48 41-3.3.1 / 2013-06-27 49+3.3.1 / 2013-06-2750 ==================51 52 * update connect53 46-3.3.0 / 2013-06-26 54+3.3.0 / 2013-06-2655 ==================56 57 * update connect58 * add support for multiple X-Forwarded-Proto values. Closes #164659 * change: remove charset from json responses. Closes #163160 * change: return actual booleans from req.accept* functions61 * fix jsonp callback array throw62 55-3.2.6 / 2013-06-02 63+3.2.6 / 2013-06-0264 ==================65 66 * update connect67 60-3.2.5 / 2013-05-21 68+3.2.5 / 2013-05-2169 ==================70 71 * update connect72 * update node-cookie73 * add: throw a meaningful error when there is no default engine74 * change generation of ETags with res.send() to GET requests only. Closes #161975 68-3.2.4 / 2013-05-09 76+3.2.4 / 2013-05-0977 ==================70- 78+79 * fix `req.subdomains` when no Host is present80 * fix `req.host` when no Host is present, return undefined81 74-3.2.3 / 2013-05-07 82+3.2.3 / 2013-05-0783 ==================84 85 * update connect / qs86 79-3.2.2 / 2013-05-03 87+3.2.2 / 2013-05-0388 ==================89 90 * update qs91 84-3.2.1 / 2013-04-29 92+3.2.1 / 2013-04-2993 ==================94 95 * add app.VERB() paths array deprecation warning96 * update connect97 * update qs and remove all ~ semver crap98 * fix: accept number as value of Signed Cookie99 92-3.2.0 / 2013-04-15 100+3.2.0 / 2013-04-15101 ==================102 103 * add "view" constructor setting to override view behaviour104 * add req.acceptsEncoding(name)105 * add req.acceptedEncodings106 * revert cookie signature change causing session race conditions99- * fix sorting of Accept values of the same quality 107+ * fix sorting of Accept values of the same quality108 101-3.1.2 / 2013-04-12 109+3.1.2 / 2013-04-12110 ==================111 112 * add support for custom Accept parameters113 * update cookie-signature114 107-3.1.1 / 2013-04-01 115+3.1.1 / 2013-04-01116 ==================117 118 * add X-Forwarded-Host support to `req.host`111- * fix relative redirects 112- * update mkdirp 119+ * fix relative redirects120+ * update mkdirp121 * update buffer-crc32122 * remove legacy app.configure() method from app template.123 124 3.1.0 / 2013-01-251089 unmodified linesmodified:Makefile+1 added
7 unmodified lines8 9 test-unit:10 @NODE_ENV=test ./node_modules/.bin/mocha \11 --reporter $(REPORTER) \12+ --globals setImmediate,clearImmediate \13 $(MOCHA_OPTS)14 15 test-acceptance:16 @NODE_ENV=test ./node_modules/.bin/mocha \18 unmodified linesmodified:package.json+2 added-2 removed
12344567812 unmodified lines2122232425252627282942 unmodified lines{ "name": "express", "description": "Sinatra inspired web development framework", "version": "3.4.0", "version": "3.4.1", "author": "TJ Holowaychuk <tj@vision-media.ca>", "contributors": [ { "name": "TJ Holowaychuk",12 unmodified lines "email": "rauchg@gmail.com" } ], "dependencies": { "connect": "2.9.0", "connect": "2.9.1", "commander": "2.0.0", "range-parser": "0.0.4", "mkdirp": "0.3.5", "cookie": "0.1.0",42 unmodified lines