Repository navigation
fix(ui): only embed http(s) learning resource URLs (backport 2.0 #36300) - #36934
Conversation
Video and Storylane resources pass source.url through getSafeHttpUrl before it becomes the iframe src, and show the invalid-URL state instead of a frame when it is not an http(s) URL. Ported by hand: 2.0 predates the player refactor on main, so the change is applied to 2.0's components. The learning-resource form change from #36300 is not needed on 2.0, whose form already validates the source URL with antd's url rule. (cherry picked from commit 8d53dbe)
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
Code Review ✅ Approved🟡 Medium risk · Restricting learning-resource iframe and article links to HTTP(S) could block legitimate non-HTTP resources and change how users access learning content. Restricts learning resource embeds and the article viewer's open-in-new-tab link to http(s) URLs, so non-http(s) sources render the invalid-URL state instead of an iframe. No issues found. VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|



Issue
Fixes #36299
Port of PR #36300 to the 2.0 release branch, plus the
ArticleViewerchange from PR #36156. On 2.0, the Video and Storylane players still putresource.source.urlinto an iframe sandboxed withallow-scripts allow-same-origin. Storylane uses it as-is, and Video falls back to it when the URL doesn't parse.2.0 predates the player refactor on
main(coreTypography/Loader, extracted embed helpers), so #36300 doesn't cherry-pick. This applies the same guard to 2.0's components.What changes
StorylaneTour/VideoPlayer: the source URL goes throughgetSafeHttpUrl(already on 2.0) before it becomes the iframesrc. A non-http(s) URL renders thelabel.invalid-urlstate instead of a frame. 2.0's YouTube/Vimeo embed logic is unchanged.VideoPlayerembed logic: moved unchanged from theuseMemocallback into a module-levelgetEmbedUrl(url), as onmain. The new http(s) check had pushed the callback's cognitive complexity to 16, over Sonar's limit of 15.ArticleViewer: the "open in new tab" link shown when an article fails to load usesgetSafeHttpUrl, as onmainsince fix(security): batch of backend security-hardening fixes #36156. Only that UI hunk is taken from fix(security): batch of backend security-hardening fixes #36156.LearningResourceFormvalidates the source URL with antd'surlrule, which already rejectsjavascript:anddata:URLs.Tests
StorylaneTourandVideoPlayertest cases, which apply cleanly to 2.0.StringUtils: 9 suites, 163 tests pass.origin/2.0, 6 of the new cases fail.tsc --noEmit: no errors in the changed component files. The two test files carryTS2741errors (missingcategories) in their mock factories. Those lines are unchanged fromorigin/2.0.🤖 Generated with Claude Code