Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master' into latest
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickebates committed May 17, 2017
2 parents 5a265c7 + 91133f4 commit 4131799
Show file tree
Hide file tree
Showing 20 changed files with 178 additions and 50 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Project Nami
===============

### Version: `1.5.7` ###
### Version: `1.5.8` ###

### Description: ###
[![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://deploy.azure.com/?repository=https://github.com/ProjectNami/projectnami/tree/latest)
Expand Down
4 changes: 4 additions & 0 deletions wp-admin/about.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@

<div class="changelog point-releases">
<h3><?php _e( 'Maintenance and Security Releases' ); ?></h3>
<p><?php printf( _n( '<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bug.',
'<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bugs.', 3 ), '4.7.5', number_format_i18n( 3 ) ); ?>
<?php printf( __( 'For more information, see <a href="%s">the release notes</a>.' ), 'https://codex.wordpress.org/Version_4.7.5' ); ?>
</p>
<p><?php printf( _n( '<strong>Version %1$s</strong> addressed %2$s bug.',
'<strong>Version %1$s</strong> addressed %2$s bugs.', 47 ), '4.7.4', number_format_i18n( 47 ) ); ?>
<?php printf( __( 'For more information, see <a href="%s">the release notes</a>.' ), 'https://codex.wordpress.org/Version_4.7.4' ); ?>
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/customize.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
<div id="customize-info" class="accordion-section customize-info">
<div class="accordion-section-title">
<span class="preview-notice"><?php
echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title site-title">' . get_bloginfo( 'name' ) . '</strong>' );
echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title site-title">' . get_bloginfo( 'name', 'display' ) . '</strong>' );
?></span>
<button type="button" class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button>
</div>
Expand Down
33 changes: 24 additions & 9 deletions wp-admin/includes/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -1091,14 +1091,28 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,

$credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => ''));

$submitted_form = wp_unslash( $_POST );

// Verify nonce, or unset submitted form field values on failure
if ( ! isset( $_POST['_fs_nonce'] ) || ! wp_verify_nonce( $_POST['_fs_nonce'], 'filesystem-credentials' ) ) {
unset(
$submitted_form['hostname'],
$submitted_form['username'],
$submitted_form['password'],
$submitted_form['public_key'],
$submitted_form['private_key'],
$submitted_form['connection_type']
);
}

// If defined, set it to that, Else, If POST'd, set it to that, If not, Set it to whatever it previously was(saved details in option)
$credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? wp_unslash( $_POST['hostname'] ) : $credentials['hostname']);
$credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? wp_unslash( $_POST['username'] ) : $credentials['username']);
$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? wp_unslash( $_POST['password'] ) : '');
$credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($submitted_form['hostname']) ? $submitted_form['hostname'] : $credentials['hostname']);
$credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($submitted_form['username']) ? $submitted_form['username'] : $credentials['username']);
$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($submitted_form['password']) ? $submitted_form['password'] : '');

// Check to see if we are setting the public/private keys for ssh
$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($_POST['public_key']) ? wp_unslash( $_POST['public_key'] ) : '');
$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($_POST['private_key']) ? wp_unslash( $_POST['private_key'] ) : '');
$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($submitted_form['public_key']) ? $submitted_form['public_key'] : '');
$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($submitted_form['private_key']) ? $submitted_form['private_key'] : '');

// Sanitize the hostname, Some people might pass in odd-data:
$credentials['hostname'] = preg_replace('|\w+://|', '', $credentials['hostname']); //Strip any schemes off
Expand All @@ -1115,8 +1129,8 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
$credentials['connection_type'] = 'ssh';
} elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { //Only the FTP Extension understands SSL
$credentials['connection_type'] = 'ftps';
} elseif ( ! empty( $_POST['connection_type'] ) ) {
$credentials['connection_type'] = wp_unslash( $_POST['connection_type'] );
} elseif ( ! empty( $submitted_form['connection_type'] ) ) {
$credentials['connection_type'] = $submitted_form['connection_type'];
} elseif ( ! isset( $credentials['connection_type'] ) ) { //All else fails (And it's not defaulted to something else saved), Default to FTP
$credentials['connection_type'] = 'ftp';
}
Expand Down Expand Up @@ -1255,11 +1269,12 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
}

foreach ( (array) $extra_fields as $field ) {
if ( isset( $_POST[ $field ] ) )
echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />';
if ( isset( $submitted_form[ $field ] ) )
echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( $submitted_form[ $field ] ) . '" />';
}
?>
<p class="request-filesystem-credentials-action-buttons">
<?php wp_nonce_field( 'filesystem-credentials', '_fs_nonce', false, true ); ?>
<button class="button cancel-button" data-js-action="close" type="button"><?php _e( 'Cancel' ); ?></button>
<?php submit_button( __( 'Proceed' ), '', 'upgrade', false ); ?>
</p>
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ $document.ready( function() {
screenMeta.init();

// This event needs to be delegated. Ticket #37973.
$body.on( 'click', 'tbody > .check-column :checkbox', function( event ) {
$body.on( 'click', 'tbody > tr > .check-column :checkbox', function( event ) {
// Shift click to select a range of checkboxes.
if ( 'undefined' == event.shiftKey ) { return true; }
if ( event.shiftKey ) {
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/js/common.min.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions wp-admin/js/customize-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -4579,6 +4579,16 @@
}
});

// Ensure preview nonce is included with every customized request, to allow post data to be read.
$.ajaxPrefilter( function injectPreviewNonce( options ) {
if ( ! /wp_customize=on/.test( options.data ) ) {
return;
}
options.data += '&' + $.param({
customize_preview_nonce: api.settings.nonce.preview
});
});

// Refresh the nonces if the preview sends updated nonces over.
api.previewer.bind( 'nonce', function( nonce ) {
$.extend( this.nonce, nonce );
Expand Down
4 changes: 2 additions & 2 deletions wp-admin/js/customize-controls.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions wp-admin/js/updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
* @type {object} filesystemCredentials.ssh Holds SSH credentials.
* @type {string} filesystemCredentials.ssh.publicKey The public key. Default empty string.
* @type {string} filesystemCredentials.ssh.privateKey The private key. Default empty string.
* @type {string} filesystemCredentials.fsNonce Filesystem credentials form nonce.
* @type {bool} filesystemCredentials.available Whether filesystem credentials have been provided.
* Default 'false'.
*/
Expand All @@ -108,6 +109,7 @@
publicKey: '',
privateKey: ''
},
fsNonce: '',
available: false
};

Expand Down Expand Up @@ -225,6 +227,7 @@
options.data = _.extend( data, {
action: action,
_ajax_nonce: wp.updates.ajaxNonce,
_fs_nonce: wp.updates.filesystemCredentials.fsNonce,
username: wp.updates.filesystemCredentials.ftp.username,
password: wp.updates.filesystemCredentials.ftp.password,
hostname: wp.updates.filesystemCredentials.ftp.hostname,
Expand Down Expand Up @@ -1705,6 +1708,7 @@
wp.updates.filesystemCredentials.ftp.connectionType = $( 'input[name="connection_type"]:checked' ).val();
wp.updates.filesystemCredentials.ssh.publicKey = $( '#public_key' ).val();
wp.updates.filesystemCredentials.ssh.privateKey = $( '#private_key' ).val();
wp.updates.filesystemCredentials.fsNonce = $( '#_fs_nonce' ).val();
wp.updates.filesystemCredentials.available = true;

// Unlock and invoke the queue.
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/js/updates.min.js

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions wp-includes/class-http.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ public function request( $url, $args = array() ) {
// Ensure redirects follow browser behaviour.
$options['hooks']->register( 'requests.before_redirect', array( get_class(), 'browser_redirect_compatibility' ) );

// Validate redirected URLs.
if ( function_exists( 'wp_kses_bad_protocol' ) && $r['reject_unsafe_urls'] ) {
$options['hooks']->register( 'requests.before_redirect', array( get_class(), 'validate_redirects' ) );
}

if ( $r['stream'] ) {
$options['filename'] = $r['filename'];
}
Expand Down Expand Up @@ -466,6 +471,20 @@ public static function browser_redirect_compatibility( $location, $headers, $dat
}
}

/**
* Validate redirected URLs.
*
* @since 4.7.5
*
* @throws Requests_Exception On unsuccessful URL validation
* @param string $location URL to redirect to.
*/
public static function validate_redirects( $location ) {
if ( ! wp_http_validate_url( $location ) ) {
throw new Requests_Exception( __('A valid URL was not provided.'), 'wp_http.redirect_failed_validation' );
}
}

/**
* Tests which transports are capable of supporting the request.
*
Expand Down
18 changes: 18 additions & 0 deletions wp-includes/class-wp-customize-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,24 @@ public function setup_theme() {
$this->wp_die( -1, __( 'Invalid changeset UUID' ) );
}

/*
* Clear incoming post data if the user lacks a CSRF token (nonce). Note that the customizer
* application will inject the customize_preview_nonce query parameter into all Ajax requests.
* For similar behavior elsewhere in WordPress, see rest_cookie_check_errors() which logs out
* a user when a valid nonce isn't present.
*/
$has_post_data_nonce = (
check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'nonce', false )
||
check_ajax_referer( 'save-customize_' . $this->get_stylesheet(), 'nonce', false )
||
check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'customize_preview_nonce', false )
);
if ( ! current_user_can( 'customize' ) || ! $has_post_data_nonce ) {
unset( $_POST['customized'] );
unset( $_REQUEST['customized'] );
}

/*
* If unauthenticated then require a valid changeset UUID to load the preview.
* In this way, the UUID serves as a secret key. If the messenger channel is present,
Expand Down
35 changes: 29 additions & 6 deletions wp-includes/class-wp-xmlrpc-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,11 @@ public function set_custom_fields($post_id, $fields) {
if ( isset($meta['id']) ) {
$meta['id'] = (int) $meta['id'];
$pmeta = get_metadata_by_mid( 'post', $meta['id'] );

if ( ! $pmeta || $pmeta->post_id != $post_id ) {
continue;
}

if ( isset($meta['key']) ) {
$meta['key'] = wp_unslash( $meta['key'] );
if ( $meta['key'] !== $pmeta->meta_key )
Expand Down Expand Up @@ -1295,10 +1300,31 @@ private function _toggle_sticky( $post_data, $update = false ) {
* @return IXR_Error|string
*/
protected function _insert_post( $user, $content_struct ) {
$defaults = array( 'post_status' => 'draft', 'post_type' => 'post', 'post_author' => 0,
'post_password' => '', 'post_excerpt' => '', 'post_content' => '', 'post_title' => '' );
$defaults = array(
'post_status' => 'draft',
'post_type' => 'post',
'post_author' => null,
'post_password' => null,
'post_excerpt' => null,
'post_content' => null,
'post_title' => null,
'post_date' => null,
'post_date_gmt' => null,
'post_format' => null,
'post_name' => null,
'post_thumbnail' => null,
'post_parent' => null,
'ping_status' => null,
'comment_status' => null,
'custom_fields' => null,
'terms_names' => null,
'terms' => null,
'sticky' => null,
'enclosure' => null,
'ID' => null,
);

$post_data = wp_parse_args( $content_struct, $defaults );
$post_data = wp_parse_args( array_intersect_key( $content_struct, $defaults ), $defaults );

$post_type = get_post_type_object( $post_data['post_type'] );
if ( ! $post_type )
Expand Down Expand Up @@ -1488,9 +1514,6 @@ protected function _insert_post( $user, $content_struct ) {

$post_data['tax_input'] = $terms;
unset( $post_data['terms'], $post_data['terms_names'] );
} else {
// Do not allow direct submission of 'tax_input', clients must use 'terms' and/or 'terms_names'.
unset( $post_data['tax_input'], $post_data['post_category'], $post_data['tags_input'] );
}

if ( isset( $post_data['post_format'] ) ) {
Expand Down
27 changes: 18 additions & 9 deletions wp-includes/js/plupload/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,24 @@ function uploadError(fileObj, errorCode, message, uploader) {
}
}

function uploadSizeError( up, file, over100mb ) {
var message;

if ( over100mb )
message = pluploadL10n.big_upload_queued.replace('%s', file.name) + ' ' + pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>');
else
message = pluploadL10n.file_exceeds_size_limit.replace('%s', file.name);

jQuery('#media-items').append('<div id="media-item-' + file.id + '" class="media-item error"><p>' + message + '</p></div>');
function uploadSizeError( up, file ) {
var message, errorDiv;

message = pluploadL10n.file_exceeds_size_limit.replace('%s', file.name);

// Construct the error div.
errorDiv = jQuery( '<div />' )
.attr( {
'id': 'media-item-' + file.id,
'class': 'media-item error'
} )
.append(
jQuery( '<p />' )
.text( message )
);

// Append the error.
jQuery('#media-items').append( errorDiv );
up.removeFile(file);
}

Expand Down
Loading

0 comments on commit 4131799

Please sign in to comment.