Skip to content

Commit b8ccb97

Browse files
authored
Merge pull request #4296 from ampproject/enforce-utf8-content-type-header
Enfore UTF-8 content-type header
2 parents d0b3e7a + 1faaf32 commit b8ccb97

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

includes/class-amp-theme-support.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,6 +2055,11 @@ public static function prepare_response( $response, $args = [] ) {
20552055
return $response;
20562056
}
20572057

2058+
// Enforce UTF-8 encoding as it is a requirement for AMP.
2059+
if ( ! headers_sent() ) {
2060+
header( 'Content-Type: text/html; charset=utf-8' );
2061+
}
2062+
20582063
/**
20592064
* Filters whether response (post-processor) caching is enabled.
20602065
*
@@ -2356,12 +2361,6 @@ public static function prepare_response( $response, $args = [] ) {
23562361
}
23572362
}
23582363

2359-
// @todo If 'utf-8' is not the blog charset, then we'll need to do some character encoding conversation or "entityification".
2360-
if ( 'utf-8' !== strtolower( get_bloginfo( 'charset' ) ) ) {
2361-
/* translators: %s: the charset of the current site. */
2362-
trigger_error( esc_html( sprintf( __( 'The database has the %s encoding when it needs to be utf-8 to work with AMP.', 'amp' ), get_bloginfo( 'charset' ) ) ), E_USER_WARNING ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
2363-
}
2364-
23652364
AMP_Validation_Manager::finalize_validation( $dom );
23662365

23672366
$response = "<!DOCTYPE html>\n";

0 commit comments

Comments
 (0)