Skip to content

Commit 2bcaccc

Browse files
committed
[MERGE #5565 @mcduke] Fix enumeration of proxy properties containing null characters
Merge pull request #5565 from mcduke:master This fixes #5492.
2 parents f469675 + 80e661c commit 2bcaccc

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

lib/Runtime/Library/JavascriptProxy.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ namespace Js
987987

988988
struct ProxyOwnkeysEnumerator : public JavascriptEnumerator
989989
{
990-
typedef JsUtil::BaseHashSet<const char16*, Recycler> VisitedNamesHashSet;
990+
typedef JsUtil::BaseHashSet<JsUtil::CharacterBuffer<WCHAR>, Recycler> VisitedNamesHashSet;
991991
Field(VisitedNamesHashSet*) visited;
992992
Field(JavascriptArray*) trapResult;
993993
Field(JavascriptProxy*) proxy;
@@ -1029,10 +1029,11 @@ namespace Js
10291029
// let desc = Reflect.getOwnPropertyDescriptor(obj, key);
10301030
Js::PropertyDescriptor desc;
10311031
BOOL ret = JavascriptOperators::GetOwnPropertyDescriptor(proxy, propertyName, scriptContext, &desc);
1032+
const JsUtil::CharacterBuffer<WCHAR> propertyString(propertyName->GetString(), propertyName->GetLength());
10321033
// if (desc && !visited.has(key)) {
1033-
if (ret && !visited->Contains(propertyName->GetSz()))
1034+
if (ret && !visited->Contains(propertyString))
10341035
{
1035-
visited->Add(propertyName->GetSz());
1036+
visited->Add(propertyString);
10361037
// if (desc.enumerable) yield key;
10371038
if (desc.IsEnumerable())
10381039
{

test/Lib/proxyenum.baseline

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
hi
2+
hello

test/Lib/proxyenum.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
// https://github.com/Microsoft/ChakraCore/issues/5492
7+
8+
const blah = {"\0":"hi","\0\0":"hello"};
9+
for (var i in new Proxy(blah, {})) console.log(blah[i]);

test/Lib/rlexe.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@
6060
<baseline />
6161
</default>
6262
</test>
63+
<test>
64+
<default>
65+
<files>proxyenum.js</files>
66+
<baseline>proxyenum.baseline</baseline>
67+
</default>
68+
</test>
6369
<!--
6470
Re-enable after 190575 is fixed
6571
<test>

0 commit comments

Comments
 (0)