-
Notifications
You must be signed in to change notification settings - Fork 67
FED-2812 Catch MouseEvent.dataTransfer null exception #398
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
Conversation
Its possible in JS for MouseEvent.dataTransfer to be null - but in Dart SDK’s interop, its non nullable.
Security InsightsNo security relevant content was detected by automated scans. Action Items
Questions or Comments? Reach out on Slack: #support-infosec. |
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.
+1
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.
+10
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.
+10
|
@Workiva/release-management-pp |
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.
+1 from RM
The Problem
In Dart SDK versions with null-safety enabled, the interop for
MouseEvent.dataTransferis non-nullable despite the JS spec fordataTransferclearly indicating that it can be null.This can cause the SDK to throw when a
MouseEventis manually constructed (e.g. in a test utility), and thedataTransfergetter is then accessed when running withsound_null_safetyenabled:The Solution
While we cannot fix the native
MouseEvent.dataTransferissue directly, we can monkey patch this flawed non-null assertion for theSyntheticMouseEvent.dataTransferproperty that all of our consumer's UI / tests will be accessing as they migrate to null safety.This PR adds an extension method that catches the Dart SDK's exception in a new
safeDataTransfergetter, and updates thewrapNativeMouseEventimplementation to makeSyntheticMouseEvent.dataTransferaccess the newsafeDataTransfergetter instead of the nativeMouseEvent.dataTransferdirectly.QA