Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite66379f

Browse files
fix: do not let setProperty change the prototype (#1899)
* fix: do not let setProperty change the prototype* test: add unit test
1 parent56b1e64 commite66379f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

‎src/util.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ util.decorateEnum = function decorateEnum(object) {
176176
util.setProperty=functionsetProperty(dst,path,value){
177177
functionsetProp(dst,path,value){
178178
varpart=path.shift();
179-
if(part==="__proto__"){
179+
if(part==="__proto__"||part==="prototype"){
180180
returndst;
181181
}
182182
if(path.length>0){

‎tests/api_util.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ tape.test("util", function(test) {
9595

9696
util.setProperty(o,'prop.subprop',{subsub2:7});
9797
test.same(o,{prop1:[5,6],prop:{subprop:[{subsub:[5,6]},{subsub2:7}]}},"should convert nested properties to array");
98+
99+
util.setProperty({},"__proto__.test","value");
100+
test.is({}.test,undefined);
101+
102+
util.setProperty({},"prototype.test","value");
103+
test.is({}.test,undefined);
104+
105+
util.setProperty({},"constructor.prototype.test","value");
106+
test.is({}.test,undefined);
98107

99108
test.end();
100109
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp