Reset port when saving credntials. Props dwenaus and DD32. fixes #8580 for trunk
git-svn-id: http://svn.automattic.com/wordpress/trunk@10198 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4fb1a0a76b
commit
6e78e3aaf4
|
@ -667,8 +667,13 @@ function request_filesystem_credentials($form_post, $type = '', $error = false)
|
||||||
$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($_POST['public_key']) ? $_POST['public_key'] : $credentials['public_key']);
|
$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($_POST['public_key']) ? $_POST['public_key'] : $credentials['public_key']);
|
||||||
$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($_POST['private_key']) ? $_POST['private_key'] : $credentials['private_key']);
|
$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($_POST['private_key']) ? $_POST['private_key'] : $credentials['private_key']);
|
||||||
|
|
||||||
|
//sanitize the hostname, Some people might pass in odd-data:
|
||||||
|
$credentials['hostname'] = preg_replace('|\w+://|', '', $credentials['hostname']); //Strip any schemes off
|
||||||
|
|
||||||
if ( strpos($credentials['hostname'], ':') )
|
if ( strpos($credentials['hostname'], ':') )
|
||||||
list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2);
|
list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2);
|
||||||
|
else
|
||||||
|
unset($credentials['port']);
|
||||||
|
|
||||||
if ( defined('FTP_SSH') || (isset($_POST['connection_type']) && 'ssh' == $_POST['connection_type']) )
|
if ( defined('FTP_SSH') || (isset($_POST['connection_type']) && 'ssh' == $_POST['connection_type']) )
|
||||||
$credentials['connection_type'] = 'ssh';
|
$credentials['connection_type'] = 'ssh';
|
||||||
|
@ -679,7 +684,10 @@ function request_filesystem_credentials($form_post, $type = '', $error = false)
|
||||||
|
|
||||||
if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) {
|
if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) {
|
||||||
$stored_credentials = $credentials;
|
$stored_credentials = $credentials;
|
||||||
unset($stored_credentials['password'], $stored_credentials['private_key'], $stored_credentials['public_key']);
|
if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code.
|
||||||
|
$stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
|
||||||
|
|
||||||
|
unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']);
|
||||||
update_option('ftp_credentials', $stored_credentials);
|
update_option('ftp_credentials', $stored_credentials);
|
||||||
return $credentials;
|
return $credentials;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue