Comparing version 0.3.7 to 0.3.8
@@ -12,8 +12,4 @@ // Load modules | ||
/* | ||
Boom(new Error) | ||
Boom(code, message) | ||
*/ | ||
exports = module.exports = internals.Boom = function () { | ||
exports = module.exports = internals.Boom = function (/* (new Error) or (code, message) */) { | ||
@@ -43,3 +39,3 @@ var self = this; | ||
if (error.message) { | ||
this.message = error.message | ||
this.message = error.message; | ||
} | ||
@@ -58,3 +54,3 @@ } | ||
if (message) { | ||
this.message = message | ||
this.message = message; | ||
} | ||
@@ -78,3 +74,3 @@ } | ||
if (this.message) { | ||
this.response.payload.message = this.message; | ||
this.response.payload.message = Hoek.escapeHtml(this.message); // Prevent XSS from error message | ||
} | ||
@@ -181,3 +177,11 @@ }; | ||
var err = new internals.Boom(500, message); | ||
err.trace = Hoek.displayStack(1); | ||
if (data && data.stack) { | ||
err.trace = data.stack.split('\n'); | ||
err.outterTrace = Hoek.displayStack(1); | ||
} | ||
else { | ||
err.trace = Hoek.displayStack(1); | ||
} | ||
err.data = data; | ||
@@ -184,0 +188,0 @@ err.response.payload.message = 'An internal server error occurred'; // Hide actual error from user |
{ | ||
"name": "boom", | ||
"description": "HTTP-friendly error objects", | ||
"version": "0.3.7", | ||
"version": "0.3.8", | ||
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)", | ||
@@ -6,0 +6,0 @@ "contributors": [], |
@@ -207,2 +207,10 @@ // Load modules | ||
}); | ||
it('uses passed in stack if its available', function (done) { | ||
var error = new Error(); | ||
error.stack = 'my stack line\nmy second stack line'; | ||
expect(Boom.internal('my message', error).trace[0]).to.equal('my stack line'); | ||
done(); | ||
}); | ||
}); | ||
@@ -226,4 +234,14 @@ | ||
}); | ||
describe('#reformat', function () { | ||
it('encodes any HTML markup in the response payload', function (done) { | ||
var boom = new Boom(new Error('<script>alert(1)</script>')); | ||
expect(boom.response.payload.message).to.not.contain('<script>'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44663
308