@@ -74,19 +74,42 @@ const sortedKeys = computed(() => {
7474 .concat (keys .filter ((key ) => ! props .includeFields .includes (key )));
7575});
7676
77- function extractValue(item : any ): any {
77+ function extractValue(item : any , depth = 0 , visited = new WeakSet ()): any {
78+ // Prevent infinite recursion with depth limit
79+ if (depth > 10 ) {
80+ return ' [Max depth reached]' ;
81+ }
82+
83+ // Handle primitive values
84+ if (item === null || item === undefined ) {
85+ return item ;
86+ }
87+ if (typeof item !== ' object' ) {
88+ return item ;
89+ }
90+
91+ // Prevent circular references
92+ if (visited .has (item )) {
93+ return ' [Circular reference]' ;
94+ }
95+ visited .add (item );
96+
7897 if (Array .isArray (item )) {
79- return item .map ((subitem : any ) => extractValue (subitem ));
98+ return item .map ((subitem : any ) => extractValue (subitem , depth + 1 , visited ));
8099 }
100+
81101 if (
82102 Object .prototype .hasOwnProperty .call (item , ' value' ) &&
83103 Object .prototype .hasOwnProperty .call (item , ' matchLevel' )
84104 ) {
85105 return item .value ;
86106 }
107+
87108 const values: Record <string , any > = {};
88109 for (const key in item ) {
89- values [key ] = extractValue (item [key ]);
110+ if (Object .prototype .hasOwnProperty .call (item , key )) {
111+ values [key ] = extractValue (item [key ], depth + 1 , visited );
112+ }
90113 }
91114 return values ;
92115}
0 commit comments