fix: enhance ProxySetHandlerTargetCheck to prevent infinite recursion with WeakSet#228
fix: enhance ProxySetHandlerTargetCheck to prevent infinite recursion with WeakSet#228piquark6046 merged 2 commits intomainfrom
ProxySetHandlerTargetCheck to prevent infinite recursion with WeakSet#228Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the userscript’s Proxy set-handler target inspection logic to avoid infinite recursion when traversing cyclic object graphs (now tracking visited objects via WeakSet).
Changes:
- Add
WeakSet-based cycle detection toProxySetHandlerTargetCheckto prevent unbounded recursion. - Remove the
ProxySetHandlerTargetCheckAndReplacehelper and the corresponding Proxyset-handler branch that performed in-place string replacement.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for (const PropertyName of Object.keys(Target)) { | ||
| const Value = (Target as Record<string, unknown>)[PropertyName] | ||
| const Descriptor = OriginalObjectGetOwnPropertyDescriptor(Target, PropertyName) | ||
|
|
||
| if ( |
There was a problem hiding this comment.
ProxySetHandlerTargetCheck reads Target[PropertyName] before checking whether the property is an accessor (descriptor.get). If the property has a getter, this access will invoke it (side effects / possible exceptions) even though the later logic tries to skip getters. Consider fetching the descriptor first and, when it has a getter, skipping the property without reading it; for data descriptors, prefer descriptor.value to avoid accidental getter execution.
| console.debug(`[${UserscriptName}]: Proxy set called for PowerLink Skeleton (target check):`, SetArgs) | ||
| BrowserWindow.document.dispatchEvent(new CustomEvent('PL2PlaceHolderProxy')) | ||
| return | ||
| } | ||
| else if (ProxySetHandlerTargetCheckAndReplace(SetArgs[0], '')) { | ||
| console.debug(`[${UserscriptName}]: Proxy set called for PowerLink Skeleton (target check and replace):`, SetArgs) | ||
| } | ||
| return OriginalReflectApply(OriginalSet, this, SetArgs) |
There was a problem hiding this comment.
This change removes the previous ProxySetHandlerTargetCheckAndReplace(...) branch (which replaced matched ader.naver.com string values with '' before calling the original setter). That’s a functional behavior change beyond the stated goal of adding cycle detection to ProxySetHandlerTargetCheck. If the replacement is still required for blocking/sanitization, consider reintroducing it with the new Visited guard (or update the PR title/description to reflect the behavior change).
No description provided.