Make WordPress Core


Ignore:
Timestamp:
03/11/2026 11:38:35 PM (8 months ago)
Author:
adamsilverstein
Message:

Editor: Skip cross-origin isolation for third-party page builders.

Document-Isolation-Policy (DIP) isolates the document and blocks same-origin iframe access that page builders rely on. Skip DIP setup when a third-party page builder overrides the block editor via a custom action query parameter.

Also gates wp_is_client_side_media_processing_enabled() on a secure context check, since SharedArrayBuffer requires a secure context (HTTPS or localhost).

Props adamsilverstein, westonruter, mukesh27, louiswol94, manhar, illuminea.
Fixes #64803.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/media/wpCrossOriginIsolation.php

    r61844 r61947  
    77 * @covers ::wp_set_up_cross_origin_isolation
    88 * @covers ::wp_start_cross_origin_isolation_output_buffer
     9 * @covers ::wp_is_client_side_media_processing_enabled
    910 */
    1011class Tests_Media_wpCrossOriginIsolation extends WP_UnitTestCase {
    … …  
    1213        /**
    1314         * Original HTTP_USER_AGENT value.
    14          *
    15          * @var string|null
    16          */
    17         private $original_user_agent;
     15         */
     16        private ?string $original_user_agent;
     17
     18        /**
     19         * Original HTTP_HOST value.
     20         */
     21        private ?string $original_http_host;
     22
     23        /**
     24         * Original HTTPS value.
     25         */
     26        private ?string $original_https;
     27
     28        /**
     29         * Original $_GET['action'] value.
     30         */
     31        private ?string $original_get_action;
    1832
    1933        public function set_up() {
    2034                parent::set_up();
    21                 $this->original_user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : null;
     35                $this->original_user_agent = $_SERVER['HTTP_USER_AGENT'] ?? null;
     36                $this->original_http_host  = $_SERVER['HTTP_HOST'] ?? null;
     37                $this->original_https      = $_SERVER['HTTPS'] ?? null;
     38                $this->original_get_action = $_GET['action'] ?? null;
    2239        }
    2340
    … …  
    2946                }
    3047
     48                if ( null === $this->original_http_host ) {
     49                        unset( $_SERVER['HTTP_HOST'] );
     50                } else {
     51                        $_SERVER['HTTP_HOST'] = $this->original_http_host;
     52                }
     53
     54                if ( null === $this->original_https ) {
     55                        unset( $_SERVER['HTTPS'] );
     56                } else {
     57                        $_SERVER['HTTPS'] = $this->original_https;
     58                }
     59
     60                if ( null === $this->original_get_action ) {
     61                        unset( $_GET['action'] );
     62                } else {
     63                        $_GET['action'] = $this->original_get_action;
     64                }
     65
    3166                // Clean up any output buffers started during tests.
    3267                while ( ob_get_level() > 1 ) {
    … …  
    126161
    127162        /**
     163         * @ticket 64803
     164         */
     165        public function test_client_side_processing_disabled_on_non_secure_origin() {
     166                $_SERVER['HTTP_HOST'] = 'example.com';
     167                $_SERVER['HTTPS']     = '';
     168
     169                $this->assertFalse(
     170                        wp_is_client_side_media_processing_enabled(),
     171                        'Client-side media processing should be disabled on non-secure, non-localhost origins.'
     172                );
     173        }
     174
     175        /**
     176         * @ticket 64803
     177         */
     178        public function test_client_side_processing_enabled_on_localhost() {
     179                $_SERVER['HTTP_HOST'] = 'localhost';
     180                $_SERVER['HTTPS']     = '';
     181
     182                $this->assertTrue(
     183                        wp_is_client_side_media_processing_enabled(),
     184                        'Client-side media processing should be enabled on localhost.'
     185                );
     186        }
     187
     188        /**
    128189         * This test must run in a separate process because the output buffer
    129190         * callback sends HTTP headers via header(), which would fail in the
Note: See TracChangeset for help on using the changeset viewer.