-
Notifications
You must be signed in to change notification settings - Fork 60
Filter only undefined event handlers to prevent CSP violations in Svelte 5 #840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: ee5d152 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for unpic-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for unpic-angular ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for unpic-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-authored-by: ascorbic <[email protected]>
Co-authored-by: ascorbic <[email protected]>
Co-authored-by: ascorbic <[email protected]>
ascorbic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to filter them out if a user has passed them in. We need to work out why they're appearing when the user hasn't
@unpic/angular
@unpic/astro
@unpic/core
@unpic/lit
@unpic/preact
@unpic/qwik
@unpic/react
@unpic/solid
@unpic/svelte
@unpic/vue
@unpic/webc
commit: |
Co-authored-by: ascorbic <[email protected]>
You're absolutely right! I've revised the approach in commit 5c18311. The root cause: Svelte 5's The fix now only filters out event handlers that are |
|
Add a changeset |
|
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details: |
ascorbic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a changeset
Co-authored-by: ascorbic <[email protected]>
Fix CSP Errors in @unpic/svelte - Complete
Root Cause
Svelte 5's type definitions include optional event handler properties (
onload?: EventHandler | undefined | null) inHTMLImgAttributes. When these properties are present but undefined in a spread object, Svelte 5 adds internal event bindings (this.__e=event) that trigger CSP violations.Solution
Filter out only event handlers that are
undefined, allowing users to explicitly pass event handlers when needed. This preserves the ability to use event handlers while preventing CSP violations from undefined handlers.All tests pass, security scans show no vulnerabilities, and changeset added for release tracking.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.