mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
prevent crash on non-string default values (#914)
This commit is contained in:
parent
f92245794b
commit
ea1932e4fc
@ -233,6 +233,10 @@ function getId(longname, id) {
|
|||||||
var getUniqueId = exports.getUniqueId = makeUniqueId;
|
var getUniqueId = exports.getUniqueId = makeUniqueId;
|
||||||
|
|
||||||
var htmlsafe = exports.htmlsafe = function(str) {
|
var htmlsafe = exports.htmlsafe = function(str) {
|
||||||
|
if (typeof str !== 'string') {
|
||||||
|
str = String(str);
|
||||||
|
}
|
||||||
|
|
||||||
return str.replace(/&/g, '&')
|
return str.replace(/&/g, '&')
|
||||||
.replace(/</g, '<');
|
.replace(/</g, '<');
|
||||||
};
|
};
|
||||||
|
|||||||
@ -473,6 +473,15 @@ describe("jsdoc/util/templateHelper", function() {
|
|||||||
var input = '<h1>Foo & Friends</h1>';
|
var input = '<h1>Foo & Friends</h1>';
|
||||||
expect( helper.htmlsafe(input) ).toBe('<h1>Foo & Friends</h1>');
|
expect( helper.htmlsafe(input) ).toBe('<h1>Foo & Friends</h1>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should convert non-strings to strings', function() {
|
||||||
|
function htmlsafe() {
|
||||||
|
return helper.htmlsafe(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(htmlsafe).not.toThrow();
|
||||||
|
expect(htmlsafe()).toBe('false');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("find", function() {
|
describe("find", function() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user