From d7b4f2d0f6ef92a5f77c566ce3a2d643e82fe808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Sun, 28 Nov 2021 16:51:15 +0100 Subject: [PATCH 01/17] From patch 15936.5.diff --- src/wp-admin/includes/network.php | 15 +++++++++------ src/wp-includes/ms-settings.php | 24 ++++++++++++++++-------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/wp-admin/includes/network.php b/src/wp-admin/includes/network.php index ae3e906fccd23..452b5fc9c8dca 100644 --- a/src/wp-admin/includes/network.php +++ b/src/wp-admin/includes/network.php @@ -138,7 +138,10 @@ function network_step1( $errors = false ) { $hostname = get_clean_basedomain(); $has_ports = strstr( $hostname, ':' ); - if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ), true ) ) ) { + /** This filter is documented in wp-includes/ms-settings.php */ + $allowed_ports = apply_filters( 'allowed_multisite_ports', array( ':80', ':443' ) ); + + if ( ( false !== $has_ports && ! in_array( $has_ports, $allowed_ports ) ) ) { echo '

' . __( 'Error:' ) . ' ' . __( 'You cannot install a network of sites with your server address.' ) . '

'; echo '

' . sprintf( /* translators: %s: Port number. */ @@ -179,7 +182,7 @@ function network_step1( $errors = false ) { } ?>

-

+

' . substr( $hostname, 4 ) . '', '' . $hostname . '', 'www' @@ -444,7 +447,7 @@ function network_step2( $errors = false ) { echo '' . __( 'Caution:' ) . ' '; printf( /* translators: 1: wp-config.php, 2: .htaccess */ - __( 'You should back up your existing %1$s and %2$s files.' ), + __( 'We recommend you back up your existing %1$s and %2$s files.' ), 'wp-config.php', '.htaccess' ); @@ -452,7 +455,7 @@ function network_step2( $errors = false ) { echo '' . __( 'Caution:' ) . ' '; printf( /* translators: 1: wp-config.php, 2: web.config */ - __( 'You should back up your existing %1$s and %2$s files.' ), + __( 'We recommend you back up your existing %1$s and %2$s files.' ), 'wp-config.php', 'web.config' ); @@ -460,7 +463,7 @@ function network_step2( $errors = false ) { echo '' . __( 'Caution:' ) . ' '; printf( /* translators: %s: wp-config.php */ - __( 'You should back up your existing %s file.' ), + __( 'We recommend you back up your existing %s file.' ), 'wp-config.php' ); } diff --git a/src/wp-includes/ms-settings.php b/src/wp-includes/ms-settings.php index 6824895880f8b..a90d405feaa36 100644 --- a/src/wp-includes/ms-settings.php +++ b/src/wp-includes/ms-settings.php @@ -54,15 +54,23 @@ // have not been populated in the global scope through something like `sunrise.php`. if ( ! isset( $current_site ) || ! isset( $current_blog ) ) { - $domain = strtolower( stripslashes( $_SERVER['HTTP_HOST'] ) ); - if ( ':80' === substr( $domain, -3 ) ) { - $domain = substr( $domain, 0, -3 ); - $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 ); - } elseif ( ':443' === substr( $domain, -4 ) ) { - $domain = substr( $domain, 0, -4 ); - $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 ); + /** + * Filters allowed HTTP ports in Multisite. + * + * @param array $allowed_ports The allowed ports. Default is [ ':80', ':443' ]. + * + * @since 5.3.0 + * + */ + $allowed_ports = apply_filters( 'allowed_multisite_ports', array( ':80', ':443' ) ); + + foreach ( $allowed_ports as $allowed_port ) { + $str_length = strlen( $allowed_port ); + if ( substr( $domain, - $str_length ) == $allowed_port ) { + $domain = substr( $domain, 0, - $str_length ); + $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, - $str_length ); + } } - $path = stripslashes( $_SERVER['REQUEST_URI'] ); if ( is_admin() ) { $path = preg_replace( '#(.*)/wp-admin/.*#', '$1/', $path ); From 5e13de0c5bb9668075dda02a315f2917071d83ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Sun, 28 Nov 2021 16:57:54 +0100 Subject: [PATCH 02/17] If site address has a port number, remove the port before sanitize_user, then re-add the port. --- src/wp-includes/ms-site.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/ms-site.php b/src/wp-includes/ms-site.php index f71bbe1fee38f..d92c045653ef7 100644 --- a/src/wp-includes/ms-site.php +++ b/src/wp-includes/ms-site.php @@ -498,7 +498,16 @@ function wp_normalize_site_data( $data ) { // Sanitize domain if passed. if ( array_key_exists( 'domain', $data ) ) { $data['domain'] = trim( $data['domain'] ); + $has_ports = strstr( $data['domain'], ':' ); + + $data['domain'] = preg_replace( '|:\d+$|', '', $data['domain'] ); // Remove ports. $data['domain'] = preg_replace( '/\s+/', '', sanitize_user( $data['domain'], true ) ); + /** This filter is documented in wp-includes/ms-settings.php */ + $allowed_ports = apply_filters( 'allowed_multisite_ports', array( ':80', ':443' ) ); + if ( ( false !== $has_ports && in_array( $has_ports, $allowed_ports ) ) ) { + $data['domain'] = $data['domain'] . $has_ports; + } + if ( is_subdomain_install() ) { $data['domain'] = str_replace( '@', '', $data['domain'] ); } @@ -977,7 +986,7 @@ function clean_blog_cache( $blog ) { * * @since 4.6.0 * - * @param string $id Site ID as a numeric string. + * @param int $id Blog ID. * @param WP_Site $blog Site object. * @param string $domain_path_key md5 hash of domain and path. */ From 4fa8d765b07189c5673d420b8f0baba362677f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Fri, 7 Jan 2022 10:28:59 +0100 Subject: [PATCH 03/17] Update src/wp-admin/includes/network.php Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com> --- src/wp-admin/includes/network.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/network.php b/src/wp-admin/includes/network.php index 452b5fc9c8dca..9fbd857e965e3 100644 --- a/src/wp-admin/includes/network.php +++ b/src/wp-admin/includes/network.php @@ -141,7 +141,7 @@ function network_step1( $errors = false ) { /** This filter is documented in wp-includes/ms-settings.php */ $allowed_ports = apply_filters( 'allowed_multisite_ports', array( ':80', ':443' ) ); - if ( ( false !== $has_ports && ! in_array( $has_ports, $allowed_ports ) ) ) { + if ( ( false !== $has_ports && is_array( $allowed_ports ) && ! in_array( $has_ports, $allowed_ports, true ) ) ) { echo '

' . __( 'Error:' ) . ' ' . __( 'You cannot install a network of sites with your server address.' ) . '

'; echo '

' . sprintf( /* translators: %s: Port number. */ From 2bf90463ca89bcda5cf502abe2760c6764309ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Fri, 7 Jan 2022 10:30:38 +0100 Subject: [PATCH 04/17] Update src/wp-includes/ms-site.php Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com> --- src/wp-includes/ms-site.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/ms-site.php b/src/wp-includes/ms-site.php index d92c045653ef7..6ff534829663f 100644 --- a/src/wp-includes/ms-site.php +++ b/src/wp-includes/ms-site.php @@ -505,7 +505,7 @@ function wp_normalize_site_data( $data ) { /** This filter is documented in wp-includes/ms-settings.php */ $allowed_ports = apply_filters( 'allowed_multisite_ports', array( ':80', ':443' ) ); if ( ( false !== $has_ports && in_array( $has_ports, $allowed_ports ) ) ) { - $data['domain'] = $data['domain'] . $has_ports; + $data['domain'] .= $has_ports; } if ( is_subdomain_install() ) { From 76643722850e87132b709f41a84b286097e76d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Fri, 7 Jan 2022 13:02:39 +0100 Subject: [PATCH 05/17] Check if $allow_ports is an array --- src/wp-includes/ms-settings.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/ms-settings.php b/src/wp-includes/ms-settings.php index a90d405feaa36..07d27e6daecc9 100644 --- a/src/wp-includes/ms-settings.php +++ b/src/wp-includes/ms-settings.php @@ -60,15 +60,16 @@ * @param array $allowed_ports The allowed ports. Default is [ ':80', ':443' ]. * * @since 5.3.0 - * */ $allowed_ports = apply_filters( 'allowed_multisite_ports', array( ':80', ':443' ) ); - foreach ( $allowed_ports as $allowed_port ) { - $str_length = strlen( $allowed_port ); - if ( substr( $domain, - $str_length ) == $allowed_port ) { - $domain = substr( $domain, 0, - $str_length ); - $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, - $str_length ); + if ( is_array( $allowed_ports ) ) { + foreach ( $allowed_ports as $allowed_port ) { + $str_length = strlen( $allowed_port ); + if ( substr( $domain, - $str_length ) === $allowed_port ) { + $domain = substr( $domain, 0, - $str_length ); + $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, - $str_length ); + } } } $path = stripslashes( $_SERVER['REQUEST_URI'] ); From c51c3192e82c8b671637af4724c6b0d93d9652a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Fri, 7 Jan 2022 13:06:07 +0100 Subject: [PATCH 06/17] Check if $allowed_ports is an array --- src/wp-includes/ms-site.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/ms-site.php b/src/wp-includes/ms-site.php index 6ff534829663f..95fc6b60d0ef5 100644 --- a/src/wp-includes/ms-site.php +++ b/src/wp-includes/ms-site.php @@ -498,13 +498,14 @@ function wp_normalize_site_data( $data ) { // Sanitize domain if passed. if ( array_key_exists( 'domain', $data ) ) { $data['domain'] = trim( $data['domain'] ); - $has_ports = strstr( $data['domain'], ':' ); + $has_ports = strstr( $data['domain'], ':' ); - $data['domain'] = preg_replace( '|:\d+$|', '', $data['domain'] ); // Remove ports. + // Remove ports. + $data['domain'] = preg_replace( '|:\d+$|', '', $data['domain'] ); $data['domain'] = preg_replace( '/\s+/', '', sanitize_user( $data['domain'], true ) ); /** This filter is documented in wp-includes/ms-settings.php */ $allowed_ports = apply_filters( 'allowed_multisite_ports', array( ':80', ':443' ) ); - if ( ( false !== $has_ports && in_array( $has_ports, $allowed_ports ) ) ) { + if ( ( false !== $has_ports && is_array( $allowed_ports ) && in_array( $has_ports, $allowed_ports, true ) ) ) { $data['domain'] .= $has_ports; } @@ -986,7 +987,7 @@ function clean_blog_cache( $blog ) { * * @since 4.6.0 * - * @param int $id Blog ID. + * @param string $id Site ID as a numeric string. * @param WP_Site $blog Site object. * @param string $domain_path_key md5 hash of domain and path. */ From f9ef5a5a7b16be9409a32cef638d5905eb590ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Fri, 7 Jan 2022 13:07:25 +0100 Subject: [PATCH 07/17] Test ports 80, 443, 8080 --- tests/phpunit/tests/multisite/site.php | 79 ++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tests/phpunit/tests/multisite/site.php b/tests/phpunit/tests/multisite/site.php index e2d4d78ddb98b..32cf9c5e2c7e9 100644 --- a/tests/phpunit/tests/multisite/site.php +++ b/tests/phpunit/tests/multisite/site.php @@ -1355,6 +1355,85 @@ public function data_wp_insert_site() { 'lang_id' => 0, ), ), + array( + array( + 'domain' => 'example.com:443', + ), + array( + 'domain' => 'example.com', + 'path' => '/', + ), + ), + array( + array( + 'domain' => 'example.com:80', + 'path' => '/foo', + ), + array( + 'domain' => 'example.com', + 'path' => '/foo/', + ), + ), + array( + array( + 'domain' => '[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]', + 'path' => '/', + ), + array( + 'domain' => '[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]', + 'path' => '/', + ), + ), + array( + array( + 'domain' => '[3ffe:2a00:100:7031::1]:8080', + 'path' => '/', + ), + array( + 'domain' => '[3ffe:2a00:100:7031::1]:8080', + 'path' => '/', + ), + ), + array( + array( + 'domain' => 'wordpress.org:8080', + 'path' => '/', + ), + array( + 'domain' => 'wordpress.org:8080', + 'path' => '/', + ), + ), + array( + array( + 'domain' => '198.143.164.252', + 'path' => '/', + ), + array( + 'domain' => '198.143.164.252', + 'path' => '/', + ), + ), + array( + array( + 'domain' => '198.143.164.252:8080', + 'path' => '/', + ), + array( + 'domain' => '198.143.164.252:8080', + 'path' => '/', + ), + ), + array( + array( + 'domain' => '198.143.164.252:80', + 'path' => '/', + ), + array( + 'domain' => '198.143.164.252', + 'path' => '/', + ), + ), array( array( 'domain' => 'example.com', From dd383d8d054a18492e91da3cdd5864bb3d3fd7a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Mon, 10 Jan 2022 00:37:25 +0100 Subject: [PATCH 08/17] Test filter allowed_multisite_ports in test_wp_normalize_site_data --- tests/phpunit/tests/multisite/site.php | 94 ++++---------------------- 1 file changed, 15 insertions(+), 79 deletions(-) diff --git a/tests/phpunit/tests/multisite/site.php b/tests/phpunit/tests/multisite/site.php index 32cf9c5e2c7e9..e7fdb8b5b6edb 100644 --- a/tests/phpunit/tests/multisite/site.php +++ b/tests/phpunit/tests/multisite/site.php @@ -1355,85 +1355,6 @@ public function data_wp_insert_site() { 'lang_id' => 0, ), ), - array( - array( - 'domain' => 'example.com:443', - ), - array( - 'domain' => 'example.com', - 'path' => '/', - ), - ), - array( - array( - 'domain' => 'example.com:80', - 'path' => '/foo', - ), - array( - 'domain' => 'example.com', - 'path' => '/foo/', - ), - ), - array( - array( - 'domain' => '[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]', - 'path' => '/', - ), - array( - 'domain' => '[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]', - 'path' => '/', - ), - ), - array( - array( - 'domain' => '[3ffe:2a00:100:7031::1]:8080', - 'path' => '/', - ), - array( - 'domain' => '[3ffe:2a00:100:7031::1]:8080', - 'path' => '/', - ), - ), - array( - array( - 'domain' => 'wordpress.org:8080', - 'path' => '/', - ), - array( - 'domain' => 'wordpress.org:8080', - 'path' => '/', - ), - ), - array( - array( - 'domain' => '198.143.164.252', - 'path' => '/', - ), - array( - 'domain' => '198.143.164.252', - 'path' => '/', - ), - ), - array( - array( - 'domain' => '198.143.164.252:8080', - 'path' => '/', - ), - array( - 'domain' => '198.143.164.252:8080', - 'path' => '/', - ), - ), - array( - array( - 'domain' => '198.143.164.252:80', - 'path' => '/', - ), - array( - 'domain' => '198.143.164.252', - 'path' => '/', - ), - ), array( array( 'domain' => 'example.com', @@ -1682,6 +1603,9 @@ public function action_wp_validate_site_deletion_prevent_deletion( $errors ) { * @dataProvider data_wp_normalize_site_data */ public function test_wp_normalize_site_data( $data, $expected ) { + add_filter( 'allowed_multisite_ports', function( $ports ) { + return array( ':80', ':443', ':8080' ); + } ); $result = wp_normalize_site_data( $data ); $this->assertSameSetsWithIndex( $expected, $result ); @@ -1753,6 +1677,18 @@ public function data_wp_normalize_site_data() { ), array(), ), + array( + array( + 'domain' => 'domainwithport.com:443', + 'domain' => 'anotherdomainwithport.com:80', + 'domain' => 'anotherwithport.com:8080', + ), + array( + 'domain' => 'domainwithport.com:443', + 'domain' => 'anotherdomainwithport.com:80', + 'domain' => 'anotherwithport.com:8080', + ) + ) ); } From 025b288bd8a8e40985e55ef07eb6c6a8ccf037c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Mon, 10 Jan 2022 00:59:37 +0100 Subject: [PATCH 09/17] Fix code formatting. --- tests/phpunit/tests/multisite/site.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/tests/multisite/site.php b/tests/phpunit/tests/multisite/site.php index e7fdb8b5b6edb..6442fde74f82e 100644 --- a/tests/phpunit/tests/multisite/site.php +++ b/tests/phpunit/tests/multisite/site.php @@ -1603,9 +1603,12 @@ public function action_wp_validate_site_deletion_prevent_deletion( $errors ) { * @dataProvider data_wp_normalize_site_data */ public function test_wp_normalize_site_data( $data, $expected ) { - add_filter( 'allowed_multisite_ports', function( $ports ) { - return array( ':80', ':443', ':8080' ); - } ); + add_filter( + 'allowed_multisite_ports', + function( $ports ) { + return array( ':80', ':443', ':8080' ); + } + ); $result = wp_normalize_site_data( $data ); $this->assertSameSetsWithIndex( $expected, $result ); @@ -1687,8 +1690,8 @@ public function data_wp_normalize_site_data() { 'domain' => 'domainwithport.com:443', 'domain' => 'anotherdomainwithport.com:80', 'domain' => 'anotherwithport.com:8080', - ) - ) + ), + ), ); } From 80ba3f095c4cdded661e1af5e7fd9da1f99c7a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Thu, 3 Mar 2022 21:02:54 +0100 Subject: [PATCH 10/17] Place @since above @param --- src/wp-includes/ms-settings.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wp-includes/ms-settings.php b/src/wp-includes/ms-settings.php index 07d27e6daecc9..11aef4e30170c 100644 --- a/src/wp-includes/ms-settings.php +++ b/src/wp-includes/ms-settings.php @@ -57,9 +57,8 @@ /** * Filters allowed HTTP ports in Multisite. * + * @since 6.0.0 * @param array $allowed_ports The allowed ports. Default is [ ':80', ':443' ]. - * - * @since 5.3.0 */ $allowed_ports = apply_filters( 'allowed_multisite_ports', array( ':80', ':443' ) ); From 1a9cb80567c83ff068a078af4f5f576e048bddae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Thu, 3 Mar 2022 21:03:20 +0100 Subject: [PATCH 11/17] Reformat param comment. --- src/wp-includes/ms-site.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/ms-site.php b/src/wp-includes/ms-site.php index 95fc6b60d0ef5..8fc6781b30eb1 100644 --- a/src/wp-includes/ms-site.php +++ b/src/wp-includes/ms-site.php @@ -987,7 +987,7 @@ function clean_blog_cache( $blog ) { * * @since 4.6.0 * - * @param string $id Site ID as a numeric string. + * @param string $id Site ID as a numeric string. * @param WP_Site $blog Site object. * @param string $domain_path_key md5 hash of domain and path. */ From 570ea183d8365192db72707dde61e6ce8e4426b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Fri, 4 Mar 2022 09:37:52 +0100 Subject: [PATCH 12/17] Update tests/phpunit/tests/multisite/site.php Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com> --- tests/phpunit/tests/multisite/site.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/multisite/site.php b/tests/phpunit/tests/multisite/site.php index 6442fde74f82e..9839b5cc2eeb5 100644 --- a/tests/phpunit/tests/multisite/site.php +++ b/tests/phpunit/tests/multisite/site.php @@ -1683,12 +1683,24 @@ public function data_wp_normalize_site_data() { array( array( 'domain' => 'domainwithport.com:443', - 'domain' => 'anotherdomainwithport.com:80', - 'domain' => 'anotherwithport.com:8080', ), array( 'domain' => 'domainwithport.com:443', + ), + ), + array( + array( + 'domain' => 'anotherdomainwithport.com:80', + ), + array( 'domain' => 'anotherdomainwithport.com:80', + ), + ), + array( + array( + 'domain' => 'anotherwithport.com:8080', + ), + array( 'domain' => 'anotherwithport.com:8080', ), ), From 31c95e37052407cf00a431abc61cad24674067aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Fri, 4 Mar 2022 09:38:00 +0100 Subject: [PATCH 13/17] Update src/wp-includes/ms-settings.php Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com> --- src/wp-includes/ms-settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/ms-settings.php b/src/wp-includes/ms-settings.php index 11aef4e30170c..1df500afa8968 100644 --- a/src/wp-includes/ms-settings.php +++ b/src/wp-includes/ms-settings.php @@ -65,7 +65,7 @@ if ( is_array( $allowed_ports ) ) { foreach ( $allowed_ports as $allowed_port ) { $str_length = strlen( $allowed_port ); - if ( substr( $domain, - $str_length ) === $allowed_port ) { + if ( str_ends_with( $domain, $allowed_port ) ) { $domain = substr( $domain, 0, - $str_length ); $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, - $str_length ); } From 5aa0f1d024335bafca867e530476463cb637f4cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Fri, 4 Mar 2022 10:06:04 +0100 Subject: [PATCH 14/17] Use str_ends_with() --- src/wp-includes/ms-settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/ms-settings.php b/src/wp-includes/ms-settings.php index 11aef4e30170c..1df500afa8968 100644 --- a/src/wp-includes/ms-settings.php +++ b/src/wp-includes/ms-settings.php @@ -65,7 +65,7 @@ if ( is_array( $allowed_ports ) ) { foreach ( $allowed_ports as $allowed_port ) { $str_length = strlen( $allowed_port ); - if ( substr( $domain, - $str_length ) === $allowed_port ) { + if ( str_ends_with( $domain, $allowed_port ) ) { $domain = substr( $domain, 0, - $str_length ); $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, - $str_length ); } From 57145dc15bdff86bbfc1db8aa158b9cd7ce4edce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Fri, 4 Mar 2022 10:06:44 +0100 Subject: [PATCH 15/17] Fix domain with port test --- tests/phpunit/tests/multisite/site.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/multisite/site.php b/tests/phpunit/tests/multisite/site.php index 6442fde74f82e..0a2dc83417af2 100644 --- a/tests/phpunit/tests/multisite/site.php +++ b/tests/phpunit/tests/multisite/site.php @@ -1683,12 +1683,11 @@ public function data_wp_normalize_site_data() { array( array( 'domain' => 'domainwithport.com:443', - 'domain' => 'anotherdomainwithport.com:80', - 'domain' => 'anotherwithport.com:8080', ), array( - 'domain' => 'domainwithport.com:443', 'domain' => 'anotherdomainwithport.com:80', + ), + array( 'domain' => 'anotherwithport.com:8080', ), ), From c4f8a974b5a6542fe6ed8d4758cdfbfc2c861c5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Fri, 4 Mar 2022 10:53:41 +0100 Subject: [PATCH 16/17] Fix domain with port test --- tests/phpunit/tests/multisite/site.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/phpunit/tests/multisite/site.php b/tests/phpunit/tests/multisite/site.php index 0a2dc83417af2..b25f54dbaee41 100644 --- a/tests/phpunit/tests/multisite/site.php +++ b/tests/phpunit/tests/multisite/site.php @@ -1684,9 +1684,22 @@ public function data_wp_normalize_site_data() { array( 'domain' => 'domainwithport.com:443', ), + array( + 'domain' => 'domainwithport.com:443', + ), + ), + array( array( 'domain' => 'anotherdomainwithport.com:80', ), + array( + 'domain' => 'anotherdomainwithport.com:80', + ), + ), + array( + array( + 'domain' => 'anotherwithport.com:8080', + ), array( 'domain' => 'anotherwithport.com:8080', ), From 43999c35fc7a51423e248ff41a61b26ea5ec123f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 27 Jan 2023 08:09:57 +0000 Subject: [PATCH 17/17] Bump actions/github-script from 6.0.0 to 6.4.0 Bumps [actions/github-script](https://github.com/actions/github-script) from 6.0.0 to 6.4.0. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/9ac08808f993958e9de277fe43a64532a609130e...98814c53be79b1d30f795b907e553d8679345975) --- updated-dependencies: - dependency-name: actions/github-script dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/slack-notifications.yml | 4 ++-- .github/workflows/test-old-branches.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml index 9db209ddea646..63963710eb407 100644 --- a/.github/workflows/slack-notifications.yml +++ b/.github/workflows/slack-notifications.yml @@ -70,7 +70,7 @@ jobs: - name: Determine the status of the previous attempt id: previous-attempt-result if: ${{ github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} - uses: actions/github-script@9ac08808f993958e9de277fe43a64532a609130e # v6.0.0 + uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0 with: script: | const workflow_run = await github.rest.actions.getWorkflowRun({ @@ -128,7 +128,7 @@ jobs: - name: Get the commit message id: current-commit-message - uses: actions/github-script@9ac08808f993958e9de277fe43a64532a609130e # v6.0.0 + uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0 if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' }} with: script: | diff --git a/.github/workflows/test-old-branches.yml b/.github/workflows/test-old-branches.yml index f0be35a2085b8..2026f097e28cd 100644 --- a/.github/workflows/test-old-branches.yml +++ b/.github/workflows/test-old-branches.yml @@ -67,7 +67,7 @@ jobs: # Run all branches monthly, but only the currently supported one twice per month. steps: - name: Dispatch workflow run - uses: actions/github-script@9ac08808f993958e9de277fe43a64532a609130e # v6.0.0 + uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0 if: ${{ github.event_name == 'push' || github.event.schedule == '0 0 15 * *' || matrix.branch == '6.0' }} with: github-token: ${{ secrets.GHA_OLD_BRANCH_DISPATCH }}