Skip to content

Commit

Permalink
Revert "Fix output buffering for cross-origin isolation (WordPress#65701
Browse files Browse the repository at this point in the history
)"

This reverts commit 35d2718.
  • Loading branch information
huubl authored Oct 2, 2024
1 parent e7042d2 commit 18c79ae
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions lib/experimental/media/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,6 @@ function gutenberg_rest_get_attachment_filesize( array $post ): ?int {
return null;
}

/**
* Filters the list of rewrite rules formatted for output to an .htaccess file.
*
* Adds support for serving wasm-vips locally.
*
* @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
* @return string Filtered rewrite rules.
*/
function gutenberg_filter_mod_rewrite_rules( string $rules ): string {
$rules .= "\n# BEGIN Gutenberg client-side media processing experiment\n" .
"AddType application/wasm wasm\n" .
"# END Gutenberg client-side media processing experiment\n";

return $rules;
}

add_filter( 'mod_rewrite_rules', 'gutenberg_filter_mod_rewrite_rules' );

/**
* Enables cross-origin isolation in the block editor.
*
Expand Down Expand Up @@ -254,11 +236,16 @@ function gutenberg_start_cross_origin_isolation_output_buffer(): void {
$coep = $is_safari ? 'require-corp' : 'credentialless';

ob_start(
function ( string $output ) use ( $coep ): string {
header( 'Cross-Origin-Opener-Policy: same-origin' );
header( "Cross-Origin-Embedder-Policy: $coep" );
function ( string $output, ?int $phase ) use ( $coep ): string {
// Only send the header when the buffer is not being cleaned.
if ( ( $phase & PHP_OUTPUT_HANDLER_CLEAN ) === 0 ) {
header( 'Cross-Origin-Opener-Policy: same-origin' );
header( "Cross-Origin-Embedder-Policy: $coep" );

$output = gutenberg_add_crossorigin_attributes( $output );
}

return gutenberg_add_crossorigin_attributes( $output );
return $output;
}
);
}
Expand Down

0 comments on commit 18c79ae

Please sign in to comment.