Skip to content

fix(ui): only embed http(s) learning resource URLs (backport 2.0 #36300) - #36934

Merged
harsh-vador merged 3 commits into
2.0from
backport/2.0-learning-resource-urls
Nov 3, 2026
Merged

harsh-vador merged 3 commits into
2.0from
backport/2.0-learning-resource-urls

Conversation

@harsh-vador

@harsh-vador harsh-vador commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Issue

Fixes #36299

Port of PR #36300 to the 2.0 release branch, plus the ArticleViewer change from PR #36156. On 2.0, the Video and Storylane players still put resource.source.url into an iframe sandboxed with allow-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 (core Typography/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 through getSafeHttpUrl (already on 2.0) before it becomes the iframe src. A non-http(s) URL renders the label.invalid-url state instead of a frame. 2.0's YouTube/Vimeo embed logic is unchanged.
  • VideoPlayer embed logic: moved unchanged from the useMemo callback into a module-level getEmbedUrl(url), as on main. 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 uses getSafeHttpUrl, as on main since 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.
  • Not ported: fix(ui): only embed http(s) learning resource URLs #36300's form change. 2.0's LearningResourceForm validates the source URL with antd's url rule, which already rejects javascript: and data: URLs.

Tests

  • fix(ui): only embed http(s) learning resource URLs #36300's StorylaneTour and VideoPlayer test cases, which apply cleanly to 2.0.
  • Learning suites plus StringUtils: 9 suites, 163 tests pass.
  • Negative control: with the two player components reverted to origin/2.0, 6 of the new cases fail.
  • eslint: 0 errors, 0 warnings. Prettier: clean.
  • tsc --noEmit: no errors in the changed component files. The two test files carry TS2741 errors (missing categories) in their mock factories. Those lines are unchanged from origin/2.0.
  • Not run locally: Playwright. It runs in this PR's CI.

🤖 Generated with Claude Code

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)
Backport of the ArticleViewer change in #36156 to 2.0: the "open in new
tab" link on an article that failed to load uses getSafeHttpUrl, so a
non-http(s) source URL renders no href.

(cherry picked from commit ca9b8c0, ArticleViewer hunk only)
@harsh-vador
harsh-vador requested a review from a team as a code owner November 3, 2026 10:29
@harsh-vador harsh-vador added UI UI specific issues safe to test Add this label to run secure Github workflows on PRs labels Nov 3, 2026
@harsh-vador
harsh-vador requested review from anuj-kumary and removed request for a team November 3, 2026 10:29
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@harsh-vador harsh-vador self-assigned this Nov 3, 2026
@harsh-vador
harsh-vador enabled auto-merge (squash) November 3, 2026 10:31
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 68%
68.54% (83381/121653) 53.51% (51790/96768) 54.2% (15383/28377)

@gitar-bot

gitar-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown
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.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

sonarqubecloud Bot commented Nov 3, 2026

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants