diff --git a/src/util.js b/src/util.js index c39d33a6a..6c508990b 100644 --- a/src/util.js +++ b/src/util.js @@ -176,7 +176,7 @@ util.decorateEnum = function decorateEnum(object) { util.setProperty = function setProperty(dst, path, value) { function setProp(dst, path, value) { var part = path.shift(); - if (part === "__proto__") { + if (part === "__proto__" || part === "prototype") { return dst; } if (path.length > 0) { diff --git a/tests/api_util.js b/tests/api_util.js index 7b6f50ffe..63da0170f 100644 --- a/tests/api_util.js +++ b/tests/api_util.js @@ -95,6 +95,15 @@ tape.test("util", function(test) { util.setProperty(o, 'prop.subprop', { subsub2: 7}); test.same(o, {prop1: [5, 6], prop: {subprop: [{subsub: [5,6]}, {subsub2: 7}]}}, "should convert nested properties to array"); + + util.setProperty({}, "__proto__.test", "value"); + test.is({}.test, undefined); + + util.setProperty({}, "prototype.test", "value"); + test.is({}.test, undefined); + + util.setProperty({}, "constructor.prototype.test", "value"); + test.is({}.test, undefined); test.end(); });