diff --git a/.gitignore b/.gitignore index ccaa248a..f459ae9f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ node_modules *.sock build yarn.lock +npm-debug.log dist coverage diff --git a/.npmignore b/.npmignore index db2fbb9d..5f60eecc 100644 --- a/.npmignore +++ b/.npmignore @@ -6,3 +6,4 @@ example dist yarn.lock coverage +bower.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 07ba5396..eadaa189 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,41 @@ +2.6.9 / 2017-09-22 +================== + + * remove ReDoS regexp in %o formatter (#504) + +2.6.8 / 2017-05-18 +================== + + * Fix: Check for undefined on browser globals (#462, @marbemac) + +2.6.7 / 2017-05-16 +================== + + * Fix: Update ms to 2.0.0 to fix regular expression denial of service vulnerability (#458, @hubdotcom) + * Fix: Inline extend function in node implementation (#452, @dougwilson) + * Docs: Fix typo (#455, @msasad) + +2.6.5 / 2017-04-27 +================== + + * Fix: null reference check on window.documentElement.style.WebkitAppearance (#447, @thebigredgeek) + * Misc: clean up browser reference checks (#447, @thebigredgeek) + * Misc: add npm-debug.log to .gitignore (@thebigredgeek) + + +2.6.4 / 2017-04-20 +================== + + * Fix: bug that would occure if process.env.DEBUG is a non-string value. (#444, @LucianBuzzo) + * Chore: ignore bower.json in npm installations. (#437, @joaovieira) + * Misc: update "ms" to v0.7.3 (@tootallnate) + 2.6.3 / 2017-03-13 ================== - * Fix: Fix for electron reference to `process.env.DEBUG` (#431, @paulcbetts) - * Docs: Changelog fix (@thebigredgeeK) + * Fix: Electron reference to `process.env.DEBUG` (#431, @paulcbetts) + * Docs: Changelog fix (@thebigredgeek) 2.6.2 / 2017-03-10 ================== diff --git a/README.md b/README.md index 4aeab13f..f67be6b3 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ Then, run the program to be debugged as usual. | Name | Purpose | |-----------|-------------------------------------------------| -| `DEBUG` | Enables/disabled specific debugging namespaces. | +| `DEBUG` | Enables/disables specific debugging namespaces. | | `DEBUG_COLORS`| Whether or not to use colors in the debug output. | | `DEBUG_DEPTH` | Object inspection depth. | | `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. | diff --git a/component.json b/component.json index e150dc47..9de26410 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", - "version": "2.6.3", + "version": "2.6.9", "keywords": [ "debug", "log", diff --git a/package.json b/package.json index 377ea962..dc787ba7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "debug", - "version": "2.6.3", + "version": "2.6.9", "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" @@ -18,7 +18,7 @@ ], "license": "MIT", "dependencies": { - "ms": "0.7.2" + "ms": "2.0.0" }, "devDependencies": { "browserify": "9.0.3", diff --git a/src/browser.js b/src/browser.js index e21c1e0b..71069249 100644 --- a/src/browser.js +++ b/src/browser.js @@ -40,20 +40,20 @@ function useColors() { // NB: In an Electron preload script, document will be defined but not fully // initialized. Since we know we're in Chrome, we'll just detect this case // explicitly - if (typeof window !== 'undefined' && window && typeof window.process !== 'undefined' && window.process.type === 'renderer') { + if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { return true; } // is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document && 'WebkitAppearance' in document.documentElement.style) || + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || // is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window && window.console && (console.firebug || (console.exception && console.table))) || + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || // is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || // double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } /** diff --git a/src/debug.js b/src/debug.js index d5d6d167..6a5e3fc9 100644 --- a/src/debug.js +++ b/src/debug.js @@ -141,7 +141,7 @@ function enable(namespaces) { exports.names = []; exports.skips = []; - var split = (namespaces || '').split(/[\s,]+/); + var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); var len = split.length; for (var i = 0; i < len; i++) { diff --git a/src/inspector-log.js b/src/inspector-log.js new file mode 100644 index 00000000..60ea6c04 --- /dev/null +++ b/src/inspector-log.js @@ -0,0 +1,15 @@ +module.exports = inspectorLog; + +// black hole +const nullStream = new (require('stream').Writable)(); +nullStream._write = () => {}; + +/** + * Outputs a `console.log()` to the Node.js Inspector console *only*. + */ +function inspectorLog() { + const stdout = console._stdout; + console._stdout = nullStream; + console.log.apply(console, arguments); + console._stdout = stdout; +} diff --git a/src/node.js b/src/node.js index 3c7407b6..b15109c9 100644 --- a/src/node.js +++ b/src/node.js @@ -85,7 +85,9 @@ function useColors() { exports.formatters.o = function(v) { this.inspectOpts.colors = this.useColors; return util.inspect(v, this.inspectOpts) - .replace(/\s*\n\s*/g, ' '); + .split('\n').map(function(str) { + return str.trim() + }).join(' '); }; /** @@ -231,7 +233,12 @@ function createWritableStdioStream (fd) { */ function init (debug) { - debug.inspectOpts = util._extend({}, exports.inspectOpts); + debug.inspectOpts = {}; + + var keys = Object.keys(exports.inspectOpts); + for (var i = 0; i < keys.length; i++) { + debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]]; + } } /** diff --git a/test/debug_spec.js b/test/debug_spec.js index 4ab4d88d..142fbe79 100644 --- a/test/debug_spec.js +++ b/test/debug_spec.js @@ -6,11 +6,11 @@ var chai , debug , sinon , sinonChai; - + if (typeof module !== 'undefined') { chai = require('chai'); expect = chai.expect; - + debug = require('../src/index'); sinon = require('sinon'); sinonChai = require("sinon-chai"); @@ -20,20 +20,24 @@ if (typeof module !== 'undefined') { describe('debug', function () { var log = debug('test'); - + log.log = sinon.stub(); - + it('passes a basic sanity check', function () { expect(log('hello world')).to.not.throw; }); + it('allows namespaces to be a non-string value', function () { + expect(debug.enable(true)).to.not.throw; + }); + context('with log function', function () { - + beforeEach(function () { debug.enable('test'); log = debug('test'); }); - + it('uses it', function () { log.log = sinon.stub(); log('using custom log function'); @@ -41,7 +45,7 @@ describe('debug', function () { expect(log.log).to.have.been.calledOnce; }); }); - + describe('custom functions', function () { var log; @@ -59,4 +63,5 @@ describe('debug', function () { }); }); }); + });