WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/27/2017 12:55:11 AM (21 months ago)
Author:
dd32
Message:

WPDB: Fix the parsing of sockets which contain colons within the socket name (used on some cloud providers).

Props natacado.
Merges [42226] to the 4.9 branch.
Fixes #42634 for 4.9.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-includes/wp-db.php

    r42120 r42229  
    16441644        $is_ipv6 = false;
    16451645
     1646        // First peel off the socket parameter from the right, if it exists.
     1647        $socket_pos = strpos( $host, ':/' );
     1648        if ( $socket_pos !== false ) {
     1649            $socket = substr( $host, $socket_pos + 1 );
     1650            $host = substr( $host, 0, $socket_pos );
     1651        }
     1652
    16461653        // We need to check for an IPv6 address first.
    16471654        // An IPv6 address will always contain at least two colons.
    16481655        if ( substr_count( $host, ':' ) > 1 ) {
    1649             $pattern = '#^(?:\[)?(?<host>[0-9a-fA-F:]+)(?:\]:(?<port>[\d]+))?(?:/(?<socket>.+))?#';
     1656            $pattern = '#^(?:\[)?(?<host>[0-9a-fA-F:]+)(?:\]:(?<port>[\d]+))?#';
    16501657            $is_ipv6 = true;
    16511658        } else {
    16521659            // We seem to be dealing with an IPv4 address.
    1653             $pattern = '#^(?<host>[^:/]*)(?::(?<port>[\d]+))?(?::(?<socket>.+))?#';
     1660            $pattern = '#^(?<host>[^:/]*)(?::(?<port>[\d]+))?#';
    16541661        }
    16551662
     
    16631670
    16641671        $host = '';
    1665         foreach ( array( 'host', 'port', 'socket' ) as $component ) {
     1672        foreach ( array( 'host', 'port' ) as $component ) {
    16661673            if ( ! empty( $matches[ $component ] ) ) {
    16671674                $$component = $matches[ $component ];
Note: See TracChangeset for help on using the changeset viewer.