-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix: YouTube embed previews render valid referrer #73316
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
Avoid nullify the iframe origin in Safari.
Ensure valid referrer is sent to meet YouTube requirements. https://developers.google.com/youtube/terms/required-minimum-functionality#embedded-player-api-client-identity
|
Size Change: -153 B (-0.01%) Total Size: 2.49 MB
ℹ️ View Unchanged
|
Adapt Sandbox to use srcdoc so that a valid referrer may be sent for YouTube embeds.
4e36d29 to
61bf86c
Compare
| // Using srcDoc instead of blob URL src to preserve referrer | ||
| // context in Safari, allowing YouTube embeds to work correctly. | ||
| srcDoc={ srcDoc } |
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.
As noted in the comment, using srcDoc rather than a Blob URL preserves the referrer in Safari.
| title={ title } | ||
| tabIndex={ tabIndex } | ||
| className="components-sandbox" | ||
| srcDoc={ srcDocHtml } |
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.
Using srcdoc rather than writing the HTML to the iframe ensures the referrer is preserved in Safari.
These changes are more complex than the previous commit (6a07db1) approach of simply using WpEmbedPreview for YouTube embed previews. These wider Sandbox changes may have repercussions for other Sandbox usages.
|
Closing this as it is unlikely to be the proper solution given how far reaching the changes are. As noted in #73288 (comment), this issue appears to originate from a bug in the Safari browser. |
Important
This was opened primarily for demonstrative purposes. We need to better understand the implications of these changes before merging this. These changes likely have repercussions, there may also be a better approach altogether.
What?
Relates to #73288. Fix failing YouTube embed previews in Safari.
Why?
YouTube embed previews currently fail with
Error 153due to YouTube's new policies requiring a valid referrer.How?
iframeto usesrcDocrather than aBlobURL so that a validoriginis set.Allow YouTube embeds to useWpEmbedPreviewrather thanSandboxto pass along the referrer.Sandboxto usesrcDocrather than writing to the document to preserve the referrer.Testing Instructions
See #73288.
Testing Instructions for Keyboard
N/A, no navigation changes.
Screenshots or screencast
N/A, no visual changes.