Make WordPress Core

Ticket #15936: 15936.patch

File 15936.patch, 4.0 KB (added by enrico.sorcinelli, 7 years ago)
  • src/wp-admin/includes/network.php

    diff --git a/src/wp-admin/includes/network.php b/src/wp-admin/includes/network.php
    index da7aec3..b008176 100644
    a b function allow_subdomain_install() { 
    5252 */
    5353function allow_subdirectory_install() {
    5454        global $wpdb;
    55                 /**
    56                 * Filters whether to enable the subdirectory installation feature in Multisite.
    57                 *
    58                 * @since 3.0.0
    59                 *
    60                 * @param bool $allow Whether to enable the subdirectory installation feature in Multisite. Default is false.
    61                 */
     55        /**
     56        * Filters whether to enable the subdirectory installation feature in Multisite.
     57        *
     58        * @since 3.0.0
     59        *
     60        * @param bool $allow Whether to enable the subdirectory installation feature in Multisite. Default is false.
     61        */
    6262        if ( apply_filters( 'allow_subdirectory_install', false ) ) {
    6363                return true;
    6464        }
    function network_step1( $errors = false ) { 
    133133
    134134        $hostname  = get_clean_basedomain();
    135135        $has_ports = strstr( $hostname, ':' );
    136         if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ) ) ) ) {
     136        /**
     137         * Filters allowed HTTP ports in Multisite.
     138         *
     139         * @since 5.0.0
     140         *
     141         * @param array $allowed_ports The allowed ports. Default is [ ':80', ':443' ].
     142         */
     143        if ( ( false !== $has_ports && ! in_array( $has_ports, apply_filters( 'allowed_multisite_ports', array( ':80', ':443' ) ) ) ) ) {
    137144                echo '<div class="error"><p><strong>' . __( 'ERROR:' ) . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
    138145                echo '<p>' . sprintf(
    139146                        /* translators: %s: port number */
  • src/wp-admin/network/site-info.php

    diff --git a/src/wp-admin/network/site-info.php b/src/wp-admin/network/site-info.php
    index 83e05ae..facec76 100644
    a b if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] ) { 
    6767
    6868                $blog_data['scheme'] = $update_parsed_url['scheme'];
    6969                $blog_data['domain'] = $update_parsed_url['host'];
     70                // Add port (if it's in allowed list)
     71                if ( ! empty( $update_parsed_url['port'] && in_array( ':' . $update_parsed_url['port'], apply_filters( 'allowed_multisite_ports', array( ':80', ':443' ) ) ) ) ) {
     72                        $blog_data['domain'] .= ':' . $update_parsed_url['port'];
     73                }
    7074                $blog_data['path']   = $update_parsed_url['path'];
    7175        }
    72 
    7376        $existing_details     = get_site( $id );
    7477        $blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' );
    7578        foreach ( $blog_data_checkboxes as $c ) {
  • src/wp-includes/ms-functions.php

    diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php
    index 984a69c..962998e 100644
    a b function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $n 
    12721272        );
    12731273        $meta     = wp_parse_args( $meta, $defaults );
    12741274
     1275        add_filter( 'sanitize_user', 'wpmu_sanitize_domain_filter', 1, 3 );
    12751276        $domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) );
     1277        remove_filter( 'sanitize_user', 'wpmu_sanitize_domain_filter', 1, 3 );
    12761278
    12771279        if ( is_subdomain_install() ) {
    12781280                $domain = str_replace( '@', '', $domain );
    function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $n 
    13391341}
    13401342
    13411343/**
     1344 * Callback for 'sanitize_user' filter allowing ports in domain string.
     1345 *
     1346 * @since 5.0.0
     1347 *
     1348 * @param string $domain       Sanitized domain.
     1349 * @param string $raw_domain   The domain prior to sanitization.
     1350 * @param bool   $strict       Whether to limit the sanitization to specific characters. Default false.
     1351 */
     1352function wpmu_sanitize_domain_filter ( $domain, $raw_domain, $strict ) {
     1353        $port = parse_url( $raw_domain, PHP_URL_PORT );
     1354        if ( ! empty($port) && in_array( ':' . $port, apply_filters( 'allowed_multisite_ports', array( ':80', ':443' ) ) ) ) {
     1355                $domain = preg_replace( "/{$port}$/", ':' . $port, $domain );
     1356        }
     1357        return $domain;
     1358}
     1359
     1360/**
    13421361 * Notifies the network admin that a new site has been activated.
    13431362 *
    13441363 * Filter {@see 'newblog_notify_siteadmin'} to change the content of