Make WordPress Core


Ignore:
Timestamp:
05/04/2024 07:23:31 PM (4 months ago)
Author:
johnbillion
Message:

Bootstrap/Load: Add support for custom ports in multisite site addresses.

This allows a Multisite network to use an address that includes a port name, such as example.com:1234, and adds support for this to the local development environment too. You can now run a Multisite installation on the local development environment, for example at localhost:8889.

This also fixes some bugs with running a single site installation on a port, and updates the testing infrastructure so that the whole test suite runs both with and without a port number.

Props djzone, scribu, nacin, ipstenu, F J Kaiser, jeremyfelt, johnjamesjacoby, spacedmonkey, PerS, Clorith, Blackbam, enrico.sorcinelli, Jules Colle, obliviousharmony, desrosj, johnbillion

Fixes #21077, #52088

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/kses.php

    r57987 r58097  
    17331733        return array(
    17341734            'valid value for type'                    => array(
    1735                 '<object type="application/pdf" data="https://example.org/foo.pdf" />',
    1736                 '<object type="application/pdf" data="https://example.org/foo.pdf" />',
     1735                '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
     1736                '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    17371737            ),
    17381738            'invalid value for type'                  => array(
    1739                 '<object type="application/exe" data="https://example.org/foo.exe" />',
     1739                '<object type="application/exe" data="https://' . WP_TESTS_DOMAIN . '/foo.exe" />',
    17401740                '',
    17411741            ),
    17421742            'multiple type attributes, last invalid'  => array(
    1743                 '<object type="application/pdf" type="application/exe" data="https://example.org/foo.pdf" />',
    1744                 '<object type="application/pdf" data="https://example.org/foo.pdf" />',
     1743                '<object type="application/pdf" type="application/exe" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
     1744                '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    17451745            ),
    17461746            'multiple type attributes, first uppercase, last invalid' => array(
    1747                 '<object TYPE="application/pdf" type="application/exe" data="https://example.org/foo.pdf" />',
    1748                 '<object TYPE="application/pdf" data="https://example.org/foo.pdf" />',
     1747                '<object TYPE="application/pdf" type="application/exe" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
     1748                '<object TYPE="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    17491749            ),
    17501750            'multiple type attributes, last upper case and invalid' => array(
    1751                 '<object type="application/pdf" TYPE="application/exe" data="https://example.org/foo.pdf" />',
    1752                 '<object type="application/pdf" data="https://example.org/foo.pdf" />',
     1751                '<object type="application/pdf" TYPE="application/exe" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
     1752                '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    17531753            ),
    17541754            'multiple type attributes, first invalid' => array(
    1755                 '<object type="application/exe" type="application/pdf" data="https://example.org/foo.pdf" />',
     1755                '<object type="application/exe" type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    17561756                '',
    17571757            ),
    17581758            'multiple type attributes, first upper case and invalid' => array(
    1759                 '<object TYPE="application/exe" type="application/pdf" data="https://example.org/foo.pdf" />',
     1759                '<object TYPE="application/exe" type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    17601760                '',
    17611761            ),
    17621762            'multiple type attributes, first invalid, last uppercase' => array(
    1763                 '<object type="application/exe" TYPE="application/pdf" data="https://example.org/foo.pdf" />',
     1763                '<object type="application/exe" TYPE="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    17641764                '',
    17651765            ),
    17661766            'multiple object tags, last invalid'      => array(
    1767                 '<object type="application/pdf" data="https://example.org/foo.pdf" /><object type="application/exe" data="https://example.org/foo.exe" />',
    1768                 '<object type="application/pdf" data="https://example.org/foo.pdf" />',
     1767                '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" /><object type="application/exe" data="https://' . WP_TESTS_DOMAIN . '/foo.exe" />',
     1768                '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    17691769            ),
    17701770            'multiple object tags, first invalid'     => array(
    1771                 '<object type="application/exe" data="https://example.org/foo.exe" /><object type="application/pdf" data="https://example.org/foo.pdf" />',
    1772                 '<object type="application/pdf" data="https://example.org/foo.pdf" />',
     1771                '<object type="application/exe" data="https://' . WP_TESTS_DOMAIN . '/foo.exe" /><object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
     1772                '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    17731773            ),
    17741774            'type attribute with partially incorrect value' => array(
    1775                 '<object type="application/pdfa" data="https://example.org/foo.pdf" />',
     1775                '<object type="application/pdfa" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    17761776                '',
    17771777            ),
    17781778            'type attribute with empty value'         => array(
    1779                 '<object type="" data="https://example.org/foo.pdf" />',
     1779                '<object type="" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    17801780                '',
    17811781            ),
    17821782            'type attribute with no value'            => array(
    1783                 '<object type data="https://example.org/foo.pdf" />',
     1783                '<object type data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    17841784                '',
    17851785            ),
    17861786            'no type attribute'                       => array(
    1787                 '<object data="https://example.org/foo.pdf" />',
     1787                '<object data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    17881788                '',
    17891789            ),
    17901790            'different protocol in url'               => array(
    1791                 '<object type="application/pdf" data="http://example.org/foo.pdf" />',
    1792                 '<object type="application/pdf" data="http://example.org/foo.pdf" />',
     1791                '<object type="application/pdf" data="http://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
     1792                '<object type="application/pdf" data="http://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    17931793            ),
    17941794            'query string on url'                     => array(
    1795                 '<object type="application/pdf" data="https://example.org/foo.pdf?lol=.pdf" />',
     1795                '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf?lol=.pdf" />',
    17961796                '',
    17971797            ),
    17981798            'fragment on url'                         => array(
    1799                 '<object type="application/pdf" data="https://example.org/foo.pdf#lol.pdf" />',
     1799                '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf#lol.pdf" />',
    18001800                '',
    18011801            ),
    18021802            'wrong extension'                         => array(
    1803                 '<object type="application/pdf" data="https://example.org/foo.php" />',
     1803                '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.php" />',
    18041804                '',
    18051805            ),
    18061806            'protocol-relative url'                   => array(
    1807                 '<object type="application/pdf" data="//example.org/foo.pdf" />',
     1807                '<object type="application/pdf" data="//' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    18081808                '',
    18091809            ),
    18101810            'unsupported protocol'                    => array(
    1811                 '<object type="application/pdf" data="ftp://example.org/foo.pdf" />',
     1811                '<object type="application/pdf" data="ftp://' . WP_TESTS_DOMAIN . '/foo.pdf" />',
    18121812                '',
    18131813            ),
     
    18171817            ),
    18181818            'url with port number-like path'          => array(
    1819                 '<object type="application/pdf" data="https://example.org/cat:8888/foo.pdf" />',
    1820                 '<object type="application/pdf" data="https://example.org/cat:8888/foo.pdf" />',
     1819                '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/cat:8888/foo.pdf" />',
     1820                '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/cat:8888/foo.pdf" />',
    18211821            ),
    18221822        );
     
    18691869     */
    18701870    public function wp_kses_upload_dir_filter( $param ) {
    1871         $url_with_port_number = is_string( $param['url'] ) ? str_replace( 'example.org', 'example.org:8888', $param['url'] ) : $param['url'];
     1871        // Take care to replace the entire domain, including cases where it already has a port number.
     1872        $parsed         = parse_url( $param['url'] );
     1873        $replace_domain = $parsed['host'];
     1874        if ( isset( $parsed['port'] ) ) {
     1875            $replace_domain .= ':' . $parsed['port'];
     1876        }
     1877
     1878        $url_with_port_number = is_string( $param['url'] ) ? str_replace( $replace_domain, 'example.org:8888', $param['url'] ) : $param['url'];
    18721879        $param['url']         = $url_with_port_number;
    18731880        return $param;
Note: See TracChangeset for help on using the changeset viewer.