Skip to content
Myr

Fixed `req.notify()`, only escape args

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 · parent 6b161d5 · Browse files · 2 files+8 added−5 removed
This commit

State

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

Diff stats

2 files+8 added−5 removed

  • tests:+6 added−3 removed
  • other:+2 added−2 removed

2 files+8 added−5 removed

modified:lib/request.js+2 added-2 removed
252 unmodified lines
253 var i = 2254 , args = arguments255 , formatters = this.app.formatters || {};256 formatters.__proto__ = defaultFormatters;257 msg = utils.miniMarkdown(utils.escape(msg));257 msg = utils.miniMarkdown(msg);258 msg = msg.replace(/%([a-zA-Z])/g, function(_, format){259 var formatter = formatters[format];260 if (formatter) return formatter(args[i++]);260 if (formatter) return formatter(utils.escape(args[i++]));261 });262 return (msgs[type] = msgs[type] || []).push(msg);263 }264};
79 unmodified lines
modified:test/request.test.js+6 added-3 removed
165 unmodified lines
166 req.notify('info', 'one').should.equal(1);167 req.notify('info').should.eql(['one']);168 169 req.notify('info', 'Email _sent_.');170 req.notify('info', '<script>');171 req.notify('info').should.eql(['Email <em>sent</em>.', '&lt;script&gt;']);170 req.notify('info', '<em>%s</em>', 'html');171 req.notify('info').should.eql(['Email <em>sent</em>.', '<em>html</em>']);172 173 req.notify('info', 'Welcome _%s_ to %s', 'TJ', 'something');174 req.notify('info').should.eql(['Welcome <em>TJ</em> to something']);175 175176 req.notify('info', 'Test %s', '<script>');177 req.notify('info').should.eql(['Test &lt;script&gt;']);178179 req.notify('info', 'TJ has %d pets', 5.12323);180 req.notify('info').should.eql(['TJ has 5 pets']);181 182 req.notify('error', 'Foo %u', 'bar');
174 unmodified lines