Make WordPress Core


Ignore:
Timestamp:
10/18/2026 10:32:14 PM (39 hours ago)
Author:
adamsilverstein
Message:

Media: stop adding crossorigin attributes in the editor.

Fix an issue where editing a post in Chromium 137+ could end in a fatal error and a blank screen when the page loaded any cross-origin resource. wp_add_crossorigin_attributes() ran WP_HTML_Tag_Processor over the whole document inside an ob_start() display handler, where errors cannot be caught. The injected crossorigin="anonymous" was not needed in the first place: Document-Isolation-Policy: isolate-and-credentialless loads cross-origin scripts, stylesheets, audio and video without credentials instead of blocking them, and forcing a CORS request broke any host that does not send Access-Control-Allow-Origin, such as media offloaded to a CDN.

The header is now sent directly by the new wp_send_document_isolation_policy_header(), and the editor page is no longer buffered or rewritten. wp_start_cross_origin_isolation_output_buffer() and wp_add_crossorigin_attributes() are deprecated; the first only sends the header and the second returns the HTML unchanged. wp_print_media_templates() no longer adds the attribute to AUDIO and VIDEO tags. Cross-origin isolation and client-side media processing are unaffected.

Follow-up to [61844], [62048], [62819].

Props b0b3k, khokansardar, arkaprabhachowdhury, westonruter, andrewserong, algorithmsunlocks, sabernhardt, swissspidy, adamsilverstein.
Fixes #65930. See #65673.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/deprecated.php

    r64436 r64489  
    66016601        return wp_truncate_slug( $slug, $length );
    66026602}
     6603
     6604/**
     6605 * Starts an output buffer that sends the Document-Isolation-Policy header
     6606 * and adds crossorigin="anonymous" to cross-origin resources.
     6607 *
     6608 * The attribute injection was dropped because `isolate-and-credentialless`
     6609 * loads cross-origin resources without it, and forcing CORS mode broke
     6610 * resources served without `Access-Control-Allow-Origin`. Only the header
     6611 * is sent now.
     6612 *
     6613 * @since 7.1.0
     6614 * @deprecated 7.2.0 Use wp_send_document_isolation_policy_header() instead.
     6615 * @see wp_send_document_isolation_policy_header()
     6616 */
     6617function wp_start_cross_origin_isolation_output_buffer(): void {
     6618        _deprecated_function( __FUNCTION__, '7.2.0', 'wp_send_document_isolation_policy_header()' );
     6619
     6620        wp_send_document_isolation_policy_header();
     6621}
     6622
     6623/**
     6624 * Adds crossorigin="anonymous" to relevant tags in the given HTML string.
     6625 *
     6626 * No longer modifies the HTML. Under `Document-Isolation-Policy:
     6627 * isolate-and-credentialless` cross-origin resources load without the
     6628 * attribute, and adding it broke resources served without CORS headers.
     6629 *
     6630 * @since 7.1.0
     6631 * @deprecated 7.2.0
     6632 *
     6633 * @param string $html HTML input.
     6634 * @return string The unmodified HTML.
     6635 */
     6636function wp_add_crossorigin_attributes( string $html ): string {
     6637        _deprecated_function( __FUNCTION__, '7.2.0' );
     6638
     6639        return $html;
     6640}
Note: See TracChangeset for help on using the changeset viewer.