Skip to content

Commit eaf5be7

Browse files
security: further harden against prototype pollution
1 parent f92b601 commit eaf5be7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/react-native-reanimated/src/createAnimatedComponent/InlinePropManager.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function inlinePropsHasChanged(
4141

4242
function getInlinePropsUpdate(inlineProps: Record<string, unknown>) {
4343
'worklet';
44-
const update: Record<string, unknown> = {};
44+
const update: Record<string, unknown> = Object.create(null);
4545
for (const [key, styleValue] of Object.entries(inlineProps)) {
4646
if (isSharedValue(styleValue)) {
4747
update[key] = styleValue.value;
@@ -63,7 +63,7 @@ function extractSharedValuesMapFromProps(
6363
Record<string, unknown> /* Initial component props */
6464
>
6565
): Record<string, unknown> {
66-
const inlineProps: Record<string, unknown> = {};
66+
const inlineProps: Record<string, unknown> = Object.create(null);
6767

6868
for (const key in props) {
6969
const value = props[key];
@@ -112,7 +112,7 @@ export function getInlineStyle(
112112
if (isFirstRender) {
113113
return getInlinePropsUpdate(style);
114114
}
115-
const newStyle: StyleProps = {};
115+
const newStyle: StyleProps = Object.create(null);
116116
for (const [key, styleValue] of Object.entries(style)) {
117117
if (
118118
!isSharedValue(styleValue) &&
@@ -127,7 +127,7 @@ export function getInlineStyle(
127127
export class InlinePropManager implements IInlinePropManager {
128128
_inlinePropsViewDescriptors: ViewDescriptorsSet | null = null;
129129
_inlinePropsMapperId: number | null = null;
130-
_inlineProps: StyleProps = {};
130+
_inlineProps: StyleProps = Object.create(null);
131131

132132
public attachInlineProps(
133133
animatedComponent: React.Component<unknown, unknown> &

0 commit comments

Comments
 (0)