<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[50072] trunk: Security, Site Health: Improve accuracy in messaging about HTTPS support.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/50072">50072</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/50072","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>flixos90</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-01-29 19:09:49 +0000 (Fri, 29 Jan 2021)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Security, Site Health: Improve accuracy in messaging about HTTPS support.

Following up on <a href="https://core.trac.wordpress.org/changeset/49904">[49904]</a>, this changeset focuses mainly on improving the guidance about the current state of HTTPS in Site Health.

* Correct the existing copy to indicate that both the Site Address and the WordPress Address need to be changed to fully switch to HTTPS.
* Link to the respective input fields via anchor links rather than to the overall General Settings screen.
* Show different copy if the site is using HTTPS for the WordPress Address (for example to have only the administration panel in HTTPS), but not for the Site Address.
* Inform the user about potential problems even when the site is already using HTTPS, for example if the SSL certificate was no longer valid.
* Always rely on fresh information for determining HTTPS support issues in Site Health, and therefore change the `https_status` test to become asynchronous.
* Rename the new private `wp_is_owned_html_output()` function to a more appropriate `wp_is_local_html_output()`.

Props adamsilverstein, flixos90, johnjamesjacoby, timothyblynjacobs.
See <a href="https://core.trac.wordpress.org/ticket/47577">#47577</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesclasswpsitehealthphp">trunk/src/wp-admin/includes/class-wp-site-health.php</a></li>
<li><a href="#trunksrcwpincludeshttpsdetectionphp">trunk/src/wp-includes/https-detection.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestsitehealthcontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php</a></li>
<li><a href="#trunktestsphpunittestshttpsdetectionphp">trunk/tests/phpunit/tests/https-detection.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestschemasetupphp">trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php</a></li>
<li><a href="#trunktestsqunitfixtureswpapigeneratedjs">trunk/tests/qunit/fixtures/wp-api-generated.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesclasswpsitehealthphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-site-health.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-site-health.php      2021-01-29 18:52:35 UTC (rev 50071)
+++ trunk/src/wp-admin/includes/class-wp-site-health.php        2021-01-29 19:09:49 UTC (rev 50072)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -108,7 +108,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        // Don't run https test on development environments.
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( $this->is_development_environment() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                unset( $tests['direct']['https_status'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         unset( $tests['async']['https_status'] );
</ins><span class="cx" style="display: block; padding: 0 10px">                         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        foreach ( $tests['direct'] as $test ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1498,6 +1498,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @return array The test results.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function get_test_https_status() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                // Enforce fresh HTTPS detection results. This is normally invoked by using cron, but for Site Health it should
+               // always rely on the latest results.
+               wp_update_https_detection_errors();
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 $result = array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'label'       => __( 'Your website is using an active HTTPS connection' ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'status'      => 'good',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1521,27 +1525,53 @@
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( ! wp_is_using_https() ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        // If the website is not using HTTPS, provide more information about whether it is supported and how it can
+                       // be enabled.
</ins><span class="cx" style="display: block; padding: 0 10px">                         $result['status'] = 'critical';
</span><span class="cx" style="display: block; padding: 0 10px">                        $result['label']  = __( 'Your website does not use HTTPS' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        if ( is_ssl() ) {
-                               $result['description'] = sprintf(
-                                       '<p>%s</p>',
-                                       sprintf(
-                                               /* translators: %s: URL to General Settings screen. */
-                                               __( 'You are accessing this website using HTTPS, but your <a href="%s">WordPress Address</a> is not set up to use HTTPS by default.' ),
-                                               esc_url( admin_url( 'options-general.php' ) )
-                                       )
-                               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( wp_is_site_url_using_https() ) {
+                               if ( is_ssl() ) {
+                                       $result['description'] = sprintf(
+                                               '<p>%s</p>',
+                                               sprintf(
+                                                       /* translators: %s: URL to Settings > General > Site Address. */
+                                                       __( 'You are accessing this website using HTTPS, but your <a href="%s">Site Address</a> is not set up to use HTTPS by default.' ),
+                                                       esc_url( admin_url( 'options-general.php' ) . '#home' )
+                                               )
+                                       );
+                               } else {
+                                       $result['description'] = sprintf(
+                                               '<p>%s</p>',
+                                               sprintf(
+                                                       /* translators: %s: URL to Settings > General > Site Address. */
+                                                       __( 'Your <a href="%s">Site Address</a> is not set up to use HTTPS.' ),
+                                                       esc_url( admin_url( 'options-general.php' ) . '#home' )
+                                               )
+                                       );
+                               }
</ins><span class="cx" style="display: block; padding: 0 10px">                         } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                $result['description'] = sprintf(
-                                       '<p>%s</p>',
-                                       sprintf(
-                                               /* translators: %s: URL to General Settings screen. */
-                                               __( 'Your <a href="%s">WordPress Address</a> is not set up to use HTTPS.' ),
-                                               esc_url( admin_url( 'options-general.php' ) )
-                                       )
-                               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         if ( is_ssl() ) {
+                                       $result['description'] = sprintf(
+                                               '<p>%s</p>',
+                                               sprintf(
+                                                       /* translators: 1: URL to Settings > General > WordPress Address, 2: URL to Settings > General > Site Address. */
+                                                       __( 'You are accessing this website using HTTPS, but your <a href="%1$s">WordPress Address</a> and <a href="%2$s">Site Address</a> are not set up to use HTTPS by default.' ),
+                                                       esc_url( admin_url( 'options-general.php' ) . '#siteurl' ),
+                                                       esc_url( admin_url( 'options-general.php' ) . '#home' )
+                                               )
+                                       );
+                               } else {
+                                       $result['description'] = sprintf(
+                                               '<p>%s</p>',
+                                               sprintf(
+                                                       /* translators: 1: URL to Settings > General > WordPress Address, 2: URL to Settings > General > Site Address. */
+                                                       __( 'Your <a href="%1$s">WordPress Address</a> and <a href="%2$s">Site Address</a> are not set up to use HTTPS.' ),
+                                                       esc_url( admin_url( 'options-general.php' ) . '#siteurl' ),
+                                                       esc_url( admin_url( 'options-general.php' ) . '#home' )
+                                               )
+                                       );
+                               }
</ins><span class="cx" style="display: block; padding: 0 10px">                         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( wp_is_https_supported() ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1561,6 +1591,36 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        __( 'Talk to your web host about supporting HTTPS for your website.' )
</span><span class="cx" style="display: block; padding: 0 10px">                                );
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                } elseif ( ! wp_is_https_supported() ) {
+                       // If the website is using HTTPS, but HTTPS is actually not supported, inform the user about the potential
+                       // problems.
+                       $result['status'] = 'critical';
+                       $result['label']  = __( 'There are problems with the HTTPS connection of your website' );
+
+                       $https_detection_errors = get_option( 'https_detection_errors' );
+                       if ( ! empty( $https_detection_errors['ssl_verification_failed'] ) ) {
+                               $result['description'] = sprintf(
+                                       '<p>%s</p>',
+                                       sprintf(
+                                               /* translators: %s: URL to Settings > General > WordPress Address. */
+                                               __( 'Your <a href="%s">WordPress Address</a> is set up to use HTTPS, but the SSL certificate appears to be invalid.' ),
+                                               esc_url( admin_url( 'options-general.php' ) . '#siteurl' )
+                                       )
+                               );
+                       } else {
+                               $result['description'] = sprintf(
+                                       '<p>%s</p>',
+                                       sprintf(
+                                               /* translators: %s: URL to Settings > General > WordPress Address. */
+                                               __( 'Your <a href="%s">WordPress Address</a> is set up to use HTTPS, but your website appears to be unavailable when using an HTTPS connection.' ),
+                                               esc_url( admin_url( 'options-general.php' ) . '#siteurl' )
+                                       )
+                               );
+                       }
+                       $result['description'] .= sprintf(
+                               '<p>%s</p>',
+                               __( 'Talk to your web host about resolving this HTTPS issue for your website.' )
+                       );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                return $result;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2200,10 +2260,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'label' => __( 'MySQL utf8mb4 support' ),
</span><span class="cx" style="display: block; padding: 0 10px">                                        'test'  => 'utf8mb4_support',
</span><span class="cx" style="display: block; padding: 0 10px">                                ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'https_status'              => array(
-                                       'label' => __( 'HTTPS status' ),
-                                       'test'  => 'https_status',
-                               ),
</del><span class="cx" style="display: block; padding: 0 10px">                                 'ssl_support'               => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                        'label' => __( 'Secure communication' ),
</span><span class="cx" style="display: block; padding: 0 10px">                                        'test'  => 'ssl_support',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2248,6 +2304,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        'has_rest'          => true,
</span><span class="cx" style="display: block; padding: 0 10px">                                        'async_direct_test' => array( WP_Site_Health::get_instance(), 'get_test_loopback_requests' ),
</span><span class="cx" style="display: block; padding: 0 10px">                                ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                'https_status'         => array(
+                                       'label'             => __( 'HTTPS status' ),
+                                       'test'              => rest_url( 'wp-site-health/v1/tests/https-status' ),
+                                       'has_rest'          => true,
+                                       'async_direct_test' => array( WP_Site_Health::get_instance(), 'get_test_https_status' ),
+                               ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'authorization_header' => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                        'label'     => __( 'Authorization header' ),
</span><span class="cx" style="display: block; padding: 0 10px">                                        'test'      => rest_url( 'wp-site-health/v1/tests/authorization-header' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2614,7 +2676,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Don't run https test on development environments.
</span><span class="cx" style="display: block; padding: 0 10px">                if ( $this->is_development_environment() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        unset( $tests['direct']['https_status'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 unset( $tests['async']['https_status'] );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                foreach ( $tests['direct'] as $test ) {
</span></span></pre></div>
<a id="trunksrcwpincludeshttpsdetectionphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/https-detection.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/https-detection.php 2021-01-29 18:52:35 UTC (rev 50071)
+++ trunk/src/wp-includes/https-detection.php   2021-01-29 19:09:49 UTC (rev 50072)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -9,28 +9,53 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * Checks whether the website is using HTTPS.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * This is based on whether the home and site URL are using HTTPS.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * This is based on whether both the home and site URL are using HTTPS.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 5.7.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @see wp_is_home_url_using_https()
+ * @see wp_is_site_url_using_https()
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @return bool True if using HTTPS, false otherwise.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_is_using_https() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( 'https' !== wp_parse_url( home_url(), PHP_URL_SCHEME ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! wp_is_home_url_using_https() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 return false;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        return wp_is_site_url_using_https();
+}
+
+/**
+ * Checks whether the current site URL is using HTTPS.
+ *
+ * @since 5.7.0
+ * @see home_url()
+ *
+ * @return bool True if using HTTPS, false otherwise.
+ */
+function wp_is_home_url_using_https() {
+       return 'https' === wp_parse_url( home_url(), PHP_URL_SCHEME );
+}
+
+/**
+ * Checks whether the current site's URL where WordPress is stored is using HTTPS.
+ *
+ * This checks the URL where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are
+ * accessible.
+ *
+ * @since 5.7.0
+ * @see site_url()
+ *
+ * @return bool True if using HTTPS, false otherwise.
+ */
+function wp_is_site_url_using_https() {
</ins><span class="cx" style="display: block; padding: 0 10px">         // Use direct option access for 'siteurl' and manually run the 'site_url'
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        // filter because site_url() will adjust the scheme based on what the
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // filter because `site_url()` will adjust the scheme based on what the
</ins><span class="cx" style="display: block; padding: 0 10px">         // current request is using.
</span><span class="cx" style="display: block; padding: 0 10px">        /** This filter is documented in wp-includes/link-template.php */
</span><span class="cx" style="display: block; padding: 0 10px">        $site_url = apply_filters( 'site_url', get_option( 'siteurl' ), '', null, null );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( 'https' !== wp_parse_url( $site_url, PHP_URL_SCHEME ) ) {
-               return false;
-       }
-
-       return true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return 'https' === wp_parse_url( $site_url, PHP_URL_SCHEME );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -104,7 +129,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! is_wp_error( $response ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $support_errors->add( 'bad_response_code', wp_remote_retrieve_response_message( $response ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                } elseif ( false === wp_is_owned_html_output( wp_remote_retrieve_body( $response ) ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         } elseif ( false === wp_is_local_html_output( wp_remote_retrieve_body( $response ) ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         $support_errors->add( 'bad_response_source', __( 'It looks like the response did not come from this site.' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -159,7 +184,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @param string $html Full HTML output string, e.g. from a HTTP response.
</span><span class="cx" style="display: block; padding: 0 10px">  * @return bool|null True/false for whether HTML was generated by this site, null if unable to determine.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function wp_is_owned_html_output( $html ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function wp_is_local_html_output( $html ) {
</ins><span class="cx" style="display: block; padding: 0 10px">         // 1. Check if HTML includes the site's Really Simple Discovery link.
</span><span class="cx" style="display: block; padding: 0 10px">        if ( has_action( 'wp_head', 'rsd_link' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $pattern = esc_url( site_url( 'xmlrpc.php?rsd', 'rpc' ) ); // See rsd_link().
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestsitehealthcontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php 2021-01-29 18:52:35 UTC (rev 50071)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php   2021-01-29 19:09:49 UTC (rev 50072)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -90,6 +90,25 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        sprintf(
</span><span class="cx" style="display: block; padding: 0 10px">                                '/%s/%s',
</span><span class="cx" style="display: block; padding: 0 10px">                                $this->rest_base,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                'https-status'
+                       ),
+                       array(
+                               array(
+                                       'methods'             => 'GET',
+                                       'callback'            => array( $this, 'test_https_status' ),
+                                       'permission_callback' => function () {
+                                               return $this->validate_request_permission( 'https_status' );
+                                       },
+                               ),
+                               'schema' => array( $this, 'get_public_item_schema' ),
+                       )
+               );
+
+               register_rest_route(
+                       $this->namespace,
+                       sprintf(
+                               '/%s/%s',
+                               $this->rest_base,
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'dotorg-communication'
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -200,6 +219,18 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Checks that the site's frontend can be accessed over HTTPS.
+        *
+        * @since 5.7.0
+        *
+        * @return array
+        */
+       public function test_https_status() {
+               $this->load_admin_textdomain();
+               return $this->site_health->get_test_https_status();
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Checks that the authorization header is valid.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 5.6.0
</span></span></pre></div>
<a id="trunktestsphpunittestshttpsdetectionphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/https-detection.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/https-detection.php     2021-01-29 18:52:35 UTC (rev 50071)
+++ trunk/tests/phpunit/tests/https-detection.php       2021-01-29 19:09:49 UTC (rev 50072)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -141,53 +141,53 @@
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 47577
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function test_wp_is_owned_html_output_via_rsd_link() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_is_local_html_output_via_rsd_link() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 // HTML includes RSD link.
</span><span class="cx" style="display: block; padding: 0 10px">                $head_tag = get_echo( 'rsd_link' );
</span><span class="cx" style="display: block; padding: 0 10px">                $html     = $this->get_sample_html_string( $head_tag );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertTrue( wp_is_owned_html_output( $html ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertTrue( wp_is_local_html_output( $html ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // HTML includes modified RSD link but same URL.
</span><span class="cx" style="display: block; padding: 0 10px">                $head_tag = str_replace( ' />', '>', get_echo( 'rsd_link' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $html     = $this->get_sample_html_string( $head_tag );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertTrue( wp_is_owned_html_output( $html ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertTrue( wp_is_local_html_output( $html ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // HTML does not include RSD link.
</span><span class="cx" style="display: block; padding: 0 10px">                $html = $this->get_sample_html_string();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertFalse( wp_is_owned_html_output( $html ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertFalse( wp_is_local_html_output( $html ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 47577
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function test_wp_is_owned_html_output_via_wlwmanifest_link() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_is_local_html_output_via_wlwmanifest_link() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 remove_action( 'wp_head', 'rsd_link' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // HTML includes WLW manifest link.
</span><span class="cx" style="display: block; padding: 0 10px">                $head_tag = get_echo( 'wlwmanifest_link' );
</span><span class="cx" style="display: block; padding: 0 10px">                $html     = $this->get_sample_html_string( $head_tag );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertTrue( wp_is_owned_html_output( $html ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertTrue( wp_is_local_html_output( $html ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // HTML includes modified WLW manifest link but same URL.
</span><span class="cx" style="display: block; padding: 0 10px">                $head_tag = str_replace( ' />', '>', get_echo( 'wlwmanifest_link' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $html     = $this->get_sample_html_string( $head_tag );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertTrue( wp_is_owned_html_output( $html ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertTrue( wp_is_local_html_output( $html ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // HTML includes WLW manifest link with alternative URL scheme.
</span><span class="cx" style="display: block; padding: 0 10px">                $head_tag = get_echo( 'wlwmanifest_link' );
</span><span class="cx" style="display: block; padding: 0 10px">                $head_tag = false !== strpos( $head_tag, 'https://' ) ? str_replace( 'https://', 'http://', $head_tag ) : str_replace( 'http://', 'https://', $head_tag );
</span><span class="cx" style="display: block; padding: 0 10px">                $html     = $this->get_sample_html_string( $head_tag );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertTrue( wp_is_owned_html_output( $html ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertTrue( wp_is_local_html_output( $html ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // HTML does not include WLW manifest link.
</span><span class="cx" style="display: block; padding: 0 10px">                $html = $this->get_sample_html_string();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertFalse( wp_is_owned_html_output( $html ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertFalse( wp_is_local_html_output( $html ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 47577
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function test_wp_is_owned_html_output_via_rest_link() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_is_local_html_output_via_rest_link() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 remove_action( 'wp_head', 'rsd_link' );
</span><span class="cx" style="display: block; padding: 0 10px">                remove_action( 'wp_head', 'wlwmanifest_link' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -194,28 +194,28 @@
</span><span class="cx" style="display: block; padding: 0 10px">                // HTML includes REST API link.
</span><span class="cx" style="display: block; padding: 0 10px">                $head_tag = get_echo( 'rest_output_link_wp_head' );
</span><span class="cx" style="display: block; padding: 0 10px">                $html     = $this->get_sample_html_string( $head_tag );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertTrue( wp_is_owned_html_output( $html ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertTrue( wp_is_local_html_output( $html ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // HTML includes modified REST API link but same URL.
</span><span class="cx" style="display: block; padding: 0 10px">                $head_tag = str_replace( ' />', '>', get_echo( 'rest_output_link_wp_head' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $html     = $this->get_sample_html_string( $head_tag );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertTrue( wp_is_owned_html_output( $html ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertTrue( wp_is_local_html_output( $html ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // HTML includes REST API link with alternative URL scheme.
</span><span class="cx" style="display: block; padding: 0 10px">                $head_tag = get_echo( 'rest_output_link_wp_head' );
</span><span class="cx" style="display: block; padding: 0 10px">                $head_tag = false !== strpos( $head_tag, 'https://' ) ? str_replace( 'https://', 'http://', $head_tag ) : str_replace( 'http://', 'https://', $head_tag );
</span><span class="cx" style="display: block; padding: 0 10px">                $html     = $this->get_sample_html_string( $head_tag );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertTrue( wp_is_owned_html_output( $html ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertTrue( wp_is_local_html_output( $html ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // HTML does not include REST API link.
</span><span class="cx" style="display: block; padding: 0 10px">                $html = $this->get_sample_html_string();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertFalse( wp_is_owned_html_output( $html ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertFalse( wp_is_local_html_output( $html ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 47577
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function test_wp_is_owned_html_output_cannot_determine() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_wp_is_local_html_output_cannot_determine() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 remove_action( 'wp_head', 'rsd_link' );
</span><span class="cx" style="display: block; padding: 0 10px">                remove_action( 'wp_head', 'wlwmanifest_link' );
</span><span class="cx" style="display: block; padding: 0 10px">                remove_action( 'wp_head', 'rest_output_link_wp_head' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -222,7 +222,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // The HTML here doesn't matter because all hooks are removed.
</span><span class="cx" style="display: block; padding: 0 10px">                $html = $this->get_sample_html_string();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertNull( wp_is_owned_html_output( $html ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertNull( wp_is_local_html_output( $html ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function record_request_url( $preempt, $parsed_args, $url ) {
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestschemasetupphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php  2021-01-29 18:52:35 UTC (rev 50071)
+++ trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php    2021-01-29 19:09:49 UTC (rev 50072)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -137,6 +137,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        '/wp-site-health/v1',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/wp-site-health/v1/tests/background-updates',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/wp-site-health/v1/tests/loopback-requests',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        '/wp-site-health/v1/tests/https-status',
</ins><span class="cx" style="display: block; padding: 0 10px">                         '/wp-site-health/v1/tests/dotorg-communication',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/wp-site-health/v1/tests/authorization-header',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/wp-site-health/v1/directory-sizes',
</span></span></pre></div>
<a id="trunktestsqunitfixtureswpapigeneratedjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/qunit/fixtures/wp-api-generated.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/qunit/fixtures/wp-api-generated.js    2021-01-29 18:52:35 UTC (rev 50071)
+++ trunk/tests/qunit/fixtures/wp-api-generated.js      2021-01-29 19:09:49 UTC (rev 50072)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6191,6 +6191,27 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 ]
</span><span class="cx" style="display: block; padding: 0 10px">             }
</span><span class="cx" style="display: block; padding: 0 10px">         },
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        "/wp-site-health/v1/tests/https-status": {
+            "namespace": "wp-site-health/v1",
+            "methods": [
+                "GET"
+            ],
+            "endpoints": [
+                {
+                    "methods": [
+                        "GET"
+                    ],
+                    "args": []
+                }
+            ],
+            "_links": {
+                "self": [
+                    {
+                        "href": "http://example.org/index.php?rest_route=/wp-site-health/v1/tests/https-status"
+                    }
+                ]
+            }
+        },
</ins><span class="cx" style="display: block; padding: 0 10px">         "/wp-site-health/v1/tests/dotorg-communication": {
</span><span class="cx" style="display: block; padding: 0 10px">             "namespace": "wp-site-health/v1",
</span><span class="cx" style="display: block; padding: 0 10px">             "methods": [
</span></span></pre>
</div>
</div>

</body>
</html>