You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
General: Improve parsing of sent HTTP Content-Type header to detect HTML response.
This improves adherence to the HTTP spec in extracting the header name and value.
Developed in #10293
Follow-up to [60936].
Props dmsnell, westonruter.
See #43258.
git-svn-id: https://develop.svn.wordpress.org/trunk@60973 602fd350-edb4-49c9-b593-d223f7449a82
Copy file name to clipboardExpand all lines: tests/phpunit/tests/template.php
+15-1Lines changed: 15 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -597,6 +597,9 @@ static function ( string $buffer ) use ( &$filter_args ): string {
597
597
PHP_INT_MAX
598
598
);
599
599
600
+
$this->assertCount( 0, headers_list(), 'Expected no headers to have been sent during unit tests.' );
601
+
ini_set( 'default_mimetype', 'text/html' ); // Since sending a header won't work.
602
+
600
603
$initial_ob_level = ob_get_level();
601
604
$this->assertTrue( wp_start_template_enhancement_output_buffer(), 'Expected wp_start_template_enhancement_output_buffer() to return true indicating the output buffer started.' );
602
605
$this->assertSame( 1, did_action( 'wp_template_enhancement_output_buffer_started' ), 'Expected the wp_template_enhancement_output_buffer_started action to have fired.' );
@@ -676,6 +679,9 @@ static function ( string $buffer ) use ( &$applied_filter ): string {
676
679
}
677
680
);
678
681
682
+
$this->assertCount( 0, headers_list(), 'Expected no headers to have been sent during unit tests.' );
683
+
ini_set( 'default_mimetype', 'text/html' ); // Since sending a header won't work.
684
+
679
685
$initial_ob_level = ob_get_level();
680
686
$this->assertTrue( wp_start_template_enhancement_output_buffer(), 'Expected wp_start_template_enhancement_output_buffer() to return true indicating the output buffer started.' );
681
687
$this->assertSame( 1, did_action( 'wp_template_enhancement_output_buffer_started' ), 'Expected the wp_template_enhancement_output_buffer_started action to have fired.' );
@@ -740,6 +746,9 @@ static function ( string $buffer ) use ( &$called_filter ): string {
740
746
}
741
747
);
742
748
749
+
$this->assertCount( 0, headers_list(), 'Expected no headers to have been sent during unit tests.' );
750
+
ini_set( 'default_mimetype', 'application/xhtml+xml' ); // Since sending a header won't work.
751
+
743
752
$initial_ob_level = ob_get_level();
744
753
$this->assertTrue( wp_start_template_enhancement_output_buffer(), 'Expected wp_start_template_enhancement_output_buffer() to return true indicating the output buffer started.' );
745
754
$this->assertSame( 1, did_action( 'wp_template_enhancement_output_buffer_started' ), 'Expected the wp_template_enhancement_output_buffer_started action to have fired.' );
@@ -749,15 +758,18 @@ static function ( string $buffer ) use ( &$called_filter ): string {
749
758
<!DOCTYPE html>
750
759
<html lang="en">
751
760
<head>
761
+
<meta charset="utf-8">
752
762
<title>Unprocessed</title>
753
763
</head>
754
764
<body>
755
765
<h1>Hello World!</h1>
756
766
<!-- ... -->
757
767
<?phpob_clean(); // Clean the buffer started by wp_start_template_enhancement_output_buffer(), allowing the following document to replace the above.. ?>
@@ -799,7 +811,9 @@ public function test_wp_start_template_enhancement_output_buffer_for_json(): voi
799
811
$this->assertSame( 1, did_action( 'wp_template_enhancement_output_buffer_started' ), 'Expected the wp_template_enhancement_output_buffer_started action to have fired.' );
800
812
$this->assertSame( $initial_ob_level + 1, ob_get_level(), 'Expected the output buffer level to have been incremented.' );
801
813
814
+
$this->assertCount( 0, headers_list(), 'Expected no headers to have been sent during unit tests.' );
802
815
ini_set( 'default_mimetype', 'application/json' ); // Since sending a header won't work.
0 commit comments