Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/slack-notifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-old-branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
15 changes: 9 additions & 6 deletions src/wp-admin/includes/network.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 && is_array( $allowed_ports ) && ! in_array( $has_ports, $allowed_ports, true ) ) ) {
echo '<div class="error"><p><strong>' . __( 'Error:' ) . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
echo '<p>' . sprintf(
/* translators: %s: Port number. */
Expand Down Expand Up @@ -179,7 +182,7 @@ function network_step1( $errors = false ) {
}
?>
<p><?php _e( 'Welcome to the Network installation process!' ); ?></p>
<p><?php _e( 'Fill in the information below and you&#8217;ll be on your way to creating a network of WordPress sites. Configuration files will be created in the next step.' ); ?></p>
<p><?php _e( 'Fill in the information below and you&#8217;ll be on your way to creating a network of WordPress sites. We will create configuration files in the next step.' ); ?></p>
<?php

if ( isset( $_POST['subdomain_install'] ) ) {
Expand Down Expand Up @@ -271,7 +274,7 @@ function network_step1( $errors = false ) {
<?php
printf(
/* translators: 1: Site URL, 2: Host name, 3: www. */
__( 'You should consider changing your site domain to %1$s before enabling the network feature. It will still be possible to visit your site using the %3$s prefix with an address like %2$s but any links will not have the %3$s prefix.' ),
__( 'We recommend you change your site domain to %1$s before enabling the network feature. It will still be possible to visit your site using the %3$s prefix with an address like %2$s but any links will not have the %3$s prefix.' ),
'<code>' . substr( $hostname, 4 ) . '</code>',
'<code>' . $hostname . '</code>',
'<code>www</code>'
Expand Down Expand Up @@ -444,23 +447,23 @@ function network_step2( $errors = false ) {
echo '<strong>' . __( 'Caution:' ) . '</strong> ';
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.' ),
'<code>wp-config.php</code>',
'<code>.htaccess</code>'
);
} elseif ( file_exists( $home_path . 'web.config' ) ) {
echo '<strong>' . __( 'Caution:' ) . '</strong> ';
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.' ),
'<code>wp-config.php</code>',
'<code>web.config</code>'
);
} else {
echo '<strong>' . __( 'Caution:' ) . '</strong> ';
printf(
/* translators: %s: wp-config.php */
__( 'You should back up your existing %s file.' ),
__( 'We recommend you back up your existing %s file.' ),
'<code>wp-config.php</code>'
);
}
Expand Down
24 changes: 16 additions & 8 deletions src/wp-includes/ms-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* @since 6.0.0
* @param array $allowed_ports The allowed ports. Default is [ ':80', ':443' ].
*/
$allowed_ports = apply_filters( 'allowed_multisite_ports', array( ':80', ':443' ) );

if ( is_array( $allowed_ports ) ) {
foreach ( $allowed_ports as $allowed_port ) {
$str_length = strlen( $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 );
}
}
}

$path = stripslashes( $_SERVER['REQUEST_URI'] );
if ( is_admin() ) {
$path = preg_replace( '#(.*)/wp-admin/.*#', '$1/', $path );
Expand Down
10 changes: 10 additions & 0 deletions src/wp-includes/ms-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,17 @@ 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'], ':' );

// 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 && is_array( $allowed_ports ) && in_array( $has_ports, $allowed_ports, true ) ) ) {
$data['domain'] .= $has_ports;
}

if ( is_subdomain_install() ) {
$data['domain'] = str_replace( '@', '', $data['domain'] );
}
Expand Down
30 changes: 30 additions & 0 deletions tests/phpunit/tests/multisite/site.php
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +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' );
}
);
$result = wp_normalize_site_data( $data );

$this->assertSameSetsWithIndex( $expected, $result );
Expand Down Expand Up @@ -1674,6 +1680,30 @@ public function data_wp_normalize_site_data() {
),
array(),
),
array(
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',
),
),
);
}

Expand Down