Skip to content
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

[Trusted Types] Don't stringify DOM attributes (#19588 redo) #27859

Closed
wants to merge 1 commit into from

Commits on Dec 29, 2023

  1. [Trusted Types] Don't stringify DOM attributes (facebook#19588 redo)

    Summary: This is a resubmit of facebook#19588 since it was never merged and closed in error. However, the issue it fixes is still relevant and will unblock rollout of the TT feature flag internally. Copying the original PR message here:
    
    -----
    
    Instead of using Trusted Types feature flag, assume that the browser would stringify the attributes, so that React-DOM doesn't have to (making interpolation into node attributes "just work" regardless of the Trusted Types enforcement and availability) . Currently only IE<=9 does not stringify attributes. This PR implicitly drops the support for IE 9.
    
    For attributes undergoing sanitizeURL, the value is stringified in sanitizeURL function, unless enableTrustedTypesIntegration is true and the value is an immutable TrustedScriptURL value. This ascertains that objects with custom toString() function cannot be used to bypass the sanitization (now that DOMPropertyOperations don't stringify on their own).
    
    Fixes facebook#19587.
    
    ## Summary
    The PR decouples the attribute stringification from the Trusted Types logic, dropping the former completely. It was only used as a workaround for a IE <=9 browser bug. A small improvement for Trusted Types would be that it moves the most important functionality from behind the flag - i.e. allows most React apps to pass trusted types into DOM sinks without enabling the feature flag.
    
    Some rare functionality and dev warnings are still gated on the flag, but those are unrelated to the stringification issue.
    
    ## Test Plan
    Appropriate tests are added.
    onionymous committed Dec 29, 2023
    Configuration menu
    Copy the full SHA
    468cea7 View commit details
    Browse the repository at this point in the history