Skip to content

fix(proxy): allow the video player scripts iDevices load - #202

Merged
erseco merged 2 commits into
mainfrom
fix/content-csp-video-player-scripts
Nov 22, 2026
Merged

erseco merged 2 commits into
mainfrom
fix/content-csp-video-player-scripts

Conversation

@erseco

@erseco erseco commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Port of the CSP half of exelearning/gdrive-exelearning#75.

Problem

The interactive video iDevice (and the other video-based games) load https://www.youtube.com/iframe_api at runtime. The content proxy serves package HTML with script-src 'self' 'unsafe-inline' 'unsafe-eval', so the browser blocks that script and the activity stays on "Loading". Plain <iframe> embeds were not affected (frame-src already allows https:).

Change

script-src now also allows an explicit list of origins, taken from what the exported iDevices in eXeLearning v4.0.0 load at runtime:

Origin Used by
www.youtube.com, www.youtube-nocookie.com, youtu.be, s.ytimg.com YouTube IFrame API
player.vimeo.com Vimeo player API
mediateca.educa.madrid.org EducaMadrid Mediateca player

Nothing else in the policy changes: connect-src 'self' still stops package scripts from calling out, and script-src is not opened to every https: origin. cdn.jsdelivr.net (used by the rubric, checklist and progress report iDevices to export PDF/images) is deliberately not allowed: Plugin Check rejects it as offloaded content under the WordPress.org guidelines, so that export keeps not working here, as before.

The policy string moved from send_headers() into html_content_security_policy() so it can be unit tested (header() is a no-op under the CLI runner).

Notes for review

  • No ADR is included. The earlier worker-src blob: relaxation had one (ADR-156-01); say if this allowlist should get one too.
  • The service-worker session bug fixed in the gdrive PR does not exist here: this plugin serves package files from PHP.

Testing

  • Two new tests in ContentProxyTest (allowlist present; scripts and connections still restricted).
  • Full PHPUnit suite in wp-env, and phpcs on the changed class.
  • Not exercised in a browser against a real package.

Interactive video iDevices load the YouTube IFrame API, which the
content proxy's script-src 'self' blocked, leaving them on "Loading".
script-src now allows an explicit list of player and export-helper
origins used by eXeLearning's own iDevices. The policy moves to a
builder so it can be unit tested.
@github-actions

Copy link
Copy Markdown
Contributor

Test in WordPress Playground

Test the plugin with the code from this branch:

Preview in WordPress Playground

ℹ️ The eXeLearning editor is fetched from the shared release and unpacked into the plugin when the playground boots, so the first load may take a few extra seconds. ELP upload, shortcode, Gutenberg block and preview work normally.

@codecov-commenter

codecov-commenter commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.44%. Comparing base (66f4643) to head (ee0072d).

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #202   +/-   ##
=========================================
  Coverage     96.43%   96.44%           
- Complexity      806      807    +1     
=========================================
  Files            36       36           
  Lines          4268     4270    +2     
=========================================
+ Hits           4116     4118    +2     
  Misses          152      152           
Flag Coverage Δ
javascript 95.85% <ø> (ø)
php 96.64% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
includes/class-content-proxy.php 94.92% <100.00%> (+0.03%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 66f4643...ee0072d. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Plugin Check rejects cdn.jsdelivr.net as offloaded content, and the
WordPress.org guidelines do not allow it. Keep only the video players.
@erseco
erseco merged commit f71d4ab into main Nov 22, 2026
5 checks passed
@erseco
erseco deleted the fix/content-csp-video-player-scripts branch November 22, 2026 12:31
@erseco erseco self-assigned this Nov 22, 2026
erseco added a commit that referenced this pull request Nov 27, 2026
Resolve the CSP conflict in ExeLearning_Content_Proxy::send_headers(): keep
select_csp()/build_html_csp() (sandbox in secure mode) and carry the video
player script origins from #202 into the strict profile through SCRIPT_ORIGINS.
html_content_security_policy() is superseded and removed; its tests now run
against build_html_csp().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants