fix: YouTube embed previews render valid referrer#73316
Closed
fix: YouTube embed previews render valid referrer#73316
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
dcalhoun
commented
Nov 14, 2025
Comment on lines
+299
to
+301
| // Using srcDoc instead of blob URL src to preserve referrer | ||
| // context in Safari, allowing YouTube embeds to work correctly. | ||
| srcDoc={ srcDoc } |
Member
Author
There was a problem hiding this comment.
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 } |
Member
Author
There was a problem hiding this comment.
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.
Member
Author
|
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. |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.