Loading
Derive <iframe> embed link from src template on frontend
What does this MR do and why?
Stacked on top of Detect embeddable URL in the RTE and offer to c... (!265667 - merged).
The FE parts of https://gitlab.com/gitlab-org/gitlab/-/work_items/637694+ (staff-only):
- Build the "view" URL for embedded content fresh from an admin-written template, using the placeholders in the original.
- We don't "re-check the sink with the browser's parser (defense in depth)".
- The suggestion to check
new URL(canonicalSrc).hostagainst the host the provider matched before rendering only makes sense if we are, in fact, renderingcanonicalSrc. But per the first part of the fix (stop shipping the raw string), we never render (or "ship")canonicalSrc; it never makes it to a link or embed as of this MR, and is only used to preserve the user's entered URL in the source in the RTE.
- The suggestion to check
Calling this typefeature and not typebug since it's a still disabled-by-default FF.
Note that we used to roundtrip other parts of the URL a user might enter, like ?t=30 on a YouTube embed, so that they'd be preserved when a reader clicked "open in new window" (though they never became a part the embed itself). We no longer do that, by design.
Screenshots or screen recordings
Source:

| What | Before | After |
|---|---|---|
| YouTube "Open in new tab" link destination | ![]() |
![]() |
| Figma "Open in new tab" link destination | ![]() |
![]() |
| Fallback links after providers disabled | ![]() |
![]() |
How to set up and validate locally
- Check out
master. - Enable the
allow_iframes_in_markdownFF. - Go to Admin → Settings → General → Embedded content.
- Check "Enable embedded content", "YouTube", and "Figma", then click "Save changes".
- Restart your Caproni cluster/GDK.
- Insert the above source text into a work item/MR description or comment.
- Hover each embed's "Open in new tab" link, in the "You are viewing external content from ..." banner. (You need to load the Figma content to see its, not that the embed actually loads; abc123 is not a valid embed ID, but it works all the same.) The link destinations should look like the first two "Before" rows.
- Go back to admin and uncheck "YouTube", and "Figma", then click "Save changes".
- Wait a minute or so for the settings cache to expire.
- Refresh the content you created before. It should look like the last "Before" row.
- Check out this branch.
- Re-enable "YouTube" and "Figma".
- Go back to the source, and edit it slightly. Add a new line between the two embeds, or some text. We need this to ensure the Markdown cache doesn't get used.
- Repeat step 7 — the link destinations should match the first two "After" rows.
- Repeat steps 8 through 10; it should look like the last "After" row.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Asherah Connor





