FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: avoid script dedup key collisions by saschabuehrle · Pull Request #39 · CopilotKit/OpenGenerativeUI · GitHub

fix: avoid script dedup key collisions - #39

Open
saschabuehrle wants to merge 1 commit into
CopilotKit:mainfrom
saschabuehrle:fix/issue-37-script-dedup-key
Open

fix: avoid script dedup key collisions#39
saschabuehrle wants to merge 1 commit into
CopilotKit:mainfrom
saschabuehrle:fix/issue-37-script-dedup-key

Conversation

Copy link
Copy Markdown

Fixes #37

The script dedup key was truncated to 16 chars, which can collide for scripts with similar prefixes. This uses the full base64 key so different scripts no longer share the same exec marker.

Greetings, saschabuehrle

JiwaniZakir left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The fix correctly addresses the dedup key collision by removing .slice(0, 16) in widget-renderer.tsx, but it introduces a different concern: btoa(key) can produce characters like +, /, and = that are technically invalid in HTML attribute names. While most browsers handle getAttribute/setAttribute leniently with these characters, relying on that behavior is fragile. Consider using a URL-safe base64 variant (replacing + with -, / with _, and stripping =) or a simple hash function instead.

Additionally, when scriptInfo.text contains a large inline script, the full base64 of that content becomes the attribute name — potentially a very long string. A short, collision-resistant hash (e.g., a 32-bit FNV or even a truncated SHA-256 via crypto.subtle) would be both safer and more efficient here. The original .slice(0, 16) was trying to keep attribute names manageable; the right fix is to use a proper hash rather than truncated base64.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Script dedup key truncation may cause collisions

2 participants


Back | FazBrowse Home | New Git URL