Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
staylor committed Jun 16, 2015
2 parents 661742b + dd0bff0 commit 79dbbab
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 60 deletions.
11 changes: 9 additions & 2 deletions wp-admin/edit-tags.php
Expand Up @@ -302,6 +302,13 @@
}

$class = ( isset( $_REQUEST['error'] ) ) ? 'error' : 'updated';

if ( is_plugin_active( 'wpcat2tag-importer/wpcat2tag-importer.php' ) ) {
$import_link = admin_url( 'admin.php?import=wpcat2tag' );
} else {
$import_link = admin_url( 'import.php' );
}

?>

<div class="wrap nosubsub">
Expand Down Expand Up @@ -347,12 +354,12 @@
?>
</p>
<?php if ( current_user_can( 'import' ) ) : ?>
<p><?php printf(__('Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.'), 'import.php') ?></p>
<p><?php printf( __( 'Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.' ), esc_url( $import_link ) ) ?></p>
<?php endif; ?>
</div>
<?php elseif ( 'post_tag' == $taxonomy && current_user_can( 'import' ) ) : ?>
<div class="form-wrap">
<p><?php printf(__('Tags can be selectively converted to categories using the <a href="%s">tag to category converter</a>.'), 'import.php') ;?></p>
<p><?php printf( __( 'Tags can be selectively converted to categories using the <a href="%s">tag to category converter</a>.' ), esc_url( $import_link ) ) ;?></p>
</div>
<?php endif;

Expand Down
2 changes: 1 addition & 1 deletion wp-includes/comment-template.php
Expand Up @@ -1438,7 +1438,7 @@ function get_comment_reply_link( $args = array(), $comment = null, $post = null
);

$link = sprintf( "<a class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>",
esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $args['respond_id'],
esc_url( add_query_arg( 'replytocom', $comment->comment_ID, get_permalink( $post->ID ) ) ) . "#" . $args['respond_id'],
$onclick,
esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
$args['reply_text']
Expand Down
144 changes: 94 additions & 50 deletions wp-includes/formatting.php
Expand Up @@ -20,6 +20,8 @@
*
* Code within certain html blocks are skipped.
*
* Do not use this function before the 'init' action hook; everything will break.
*
* @since 0.71
*
* @global array $wp_cockneyreplace Array of formatted entities for certain common phrases
Expand Down Expand Up @@ -102,11 +104,16 @@ function wptexturize( $text, $reset = false ) {
if ( isset($wp_cockneyreplace) ) {
$cockney = array_keys( $wp_cockneyreplace );
$cockneyreplace = array_values( $wp_cockneyreplace );
} elseif ( "'" != $apos ) { // Only bother if we're doing a replacement.
$cockney = array( "'tain't", "'twere", "'twas", "'tis", "'twill", "'til", "'bout", "'nuff", "'round", "'cause", "'em" );
$cockneyreplace = array( $apos . "tain" . $apos . "t", $apos . "twere", $apos . "twas", $apos . "tis", $apos . "twill", $apos . "til", $apos . "bout", $apos . "nuff", $apos . "round", $apos . "cause", $apos . "em" );
} else {
$cockney = $cockneyreplace = array();
/* translators: This is a comma-separated list of words that defy the syntax of quotations in normal use,
* for example... 'We do not have enough words yet' ... is a typical quoted phrase. But when we write
* lines of code 'til we have enough of 'em, then we need to insert apostrophes instead of quotes.
*/
$cockney = explode( ',', _x( "'tain't,'twere,'twas,'tis,'twill,'til,'bout,'nuff,'round,'cause,'em",
'Comma-separated list of words to texturize in your language' ) );

$cockneyreplace = explode( ',', _x( '&#8217;tain&#8217;t,&#8217;twere,&#8217;twas,&#8217;tis,&#8217;twill,&#8217;til,&#8217;bout,&#8217;nuff,&#8217;round,&#8217;cause,&#8217;em',
'Comma-separated list of replacement words in your language' ) );
}

$static_characters = array_merge( array( '...', '``', '\'\'', ' (tm)' ), $cockney );
Expand All @@ -122,10 +129,10 @@ function wptexturize( $text, $reset = false ) {

// '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation.
if ( "'" !== $apos || "'" !== $closing_single_quote ) {
$dynamic[ '/\'(\d\d)\'(?=\Z|[.,)}\-\]]|&gt;|' . $spaces . ')/' ] = $apos . '$1' . $closing_single_quote;
$dynamic[ '/\'(\d\d)\'(?=\Z|[.,:;!?)}\-\]]|&gt;|' . $spaces . ')/' ] = $apos . '$1' . $closing_single_quote;
}
if ( "'" !== $apos || '"' !== $closing_quote ) {
$dynamic[ '/\'(\d\d)"(?=\Z|[.,)}\-\]]|&gt;|' . $spaces . ')/' ] = $apos . '$1' . $closing_quote;
$dynamic[ '/\'(\d\d)"(?=\Z|[.,:;!?)}\-\]]|&gt;|' . $spaces . ')/' ] = $apos . '$1' . $closing_quote;
}

// '99 '99s '99's (apostrophe) But never '9 or '99% or '999 or '99.0.
Expand All @@ -145,7 +152,7 @@ function wptexturize( $text, $reset = false ) {

// Apostrophe in a word. No spaces, double apostrophes, or other punctuation.
if ( "'" !== $apos ) {
$dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos;
$dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;!?"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos;
}

// 9' (prime)
Expand All @@ -155,7 +162,7 @@ function wptexturize( $text, $reset = false ) {

// Single quotes followed by spaces or ending punctuation.
if ( "'" !== $closing_single_quote ) {
$dynamic[ '/\'(?=\Z|[.,)}\-\]]|&gt;|' . $spaces . ')/' ] = $closing_single_quote;
$dynamic[ '/\'(?=\Z|[.,:;!?)}\-\]]|&gt;|' . $spaces . ')/' ] = $closing_single_quote;
}

$dynamic_characters['apos'] = array_keys( $dynamic );
Expand Down Expand Up @@ -3358,16 +3365,19 @@ function sanitize_option( $option, $value ) {
global $wpdb;

$original_value = $value;
$error = '';

switch ( $option ) {
case 'admin_email' :
case 'new_admin_email' :
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
$value = sanitize_email( $value );
if ( ! is_email( $value ) ) {
$value = get_option( $option ); // Resets option to stored value in the case of failed sanitization
if ( function_exists( 'add_settings_error' ) )
add_settings_error( $option, 'invalid_admin_email', __( 'The email address entered did not appear to be a valid email address. Please enter a valid email address.' ) );
if ( is_wp_error( $value ) ) {
$error = $value->get_error_message();
} else {
$value = sanitize_email( $value );
if ( ! is_email( $value ) ) {
$error = __( 'The email address entered did not appear to be a valid email address. Please enter a valid email address.' );
}
}
break;

Expand Down Expand Up @@ -3412,8 +3422,12 @@ function sanitize_option( $option, $value ) {
case 'blogdescription':
case 'blogname':
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
$value = wp_kses_post( $value );
$value = esc_html( $value );
if ( is_wp_error( $value ) ) {
$error = $value->get_error_message();
} else {
$value = wp_kses_post( $value );
$value = esc_html( $value );
}
break;

case 'blog_charset':
Expand All @@ -3435,8 +3449,12 @@ function sanitize_option( $option, $value ) {
case 'mailserver_pass':
case 'upload_path':
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
$value = strip_tags( $value );
$value = wp_kses_data( $value );
if ( is_wp_error( $value ) ) {
$error = $value->get_error_message();
} else {
$value = strip_tags( $value );
$value = wp_kses_data( $value );
}
break;

case 'ping_sites':
Expand All @@ -3452,23 +3470,27 @@ function sanitize_option( $option, $value ) {

case 'siteurl':
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
if ( (bool)preg_match( '#http(s?)://(.+)#i', $value) ) {
$value = esc_url_raw($value);
if ( is_wp_error( $value ) ) {
$error = $value->get_error_message();
} else {
$value = get_option( $option ); // Resets option to stored value in the case of failed sanitization
if ( function_exists('add_settings_error') )
add_settings_error('siteurl', 'invalid_siteurl', __('The WordPress address you entered did not appear to be a valid URL. Please enter a valid URL.'));
if ( preg_match( '#http(s?)://(.+)#i', $value ) ) {
$value = esc_url_raw( $value );
} else {
$error = __( 'The WordPress address you entered did not appear to be a valid URL. Please enter a valid URL.' );
}
}
break;

case 'home':
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
if ( (bool)preg_match( '#http(s?)://(.+)#i', $value) ) {
$value = esc_url_raw($value);
if ( is_wp_error( $value ) ) {
$error = $value->get_error_message();
} else {
$value = get_option( $option ); // Resets option to stored value in the case of failed sanitization
if ( function_exists('add_settings_error') )
add_settings_error('home', 'invalid_home', __('The Site address you entered did not appear to be a valid URL. Please enter a valid URL.'));
if ( preg_match( '#http(s?)://(.+)#i', $value ) ) {
$value = esc_url_raw( $value );
} else {
$error = __( 'The Site address you entered did not appear to be a valid URL. Please enter a valid URL.' );
}
}
break;

Expand All @@ -3484,47 +3506,58 @@ function sanitize_option( $option, $value ) {

case 'illegal_names':
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
if ( ! is_array( $value ) )
$value = explode( ' ', $value );
if ( is_wp_error( $value ) ) {
$error = $value->get_error_message();
} else {
if ( ! is_array( $value ) )
$value = explode( ' ', $value );

$value = array_values( array_filter( array_map( 'trim', $value ) ) );
$value = array_values( array_filter( array_map( 'trim', $value ) ) );

if ( ! $value )
$value = '';
if ( ! $value )
$value = '';
}
break;

case 'limited_email_domains':
case 'banned_email_domains':
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
if ( ! is_array( $value ) )
$value = explode( "\n", $value );
if ( is_wp_error( $value ) ) {
$error = $value->get_error_message();
} else {
if ( ! is_array( $value ) )
$value = explode( "\n", $value );

$domains = array_values( array_filter( array_map( 'trim', $value ) ) );
$value = array();
$domains = array_values( array_filter( array_map( 'trim', $value ) ) );
$value = array();

foreach ( $domains as $domain ) {
if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) )
$value[] = $domain;
foreach ( $domains as $domain ) {
if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) ) {
$value[] = $domain;
}
}
if ( ! $value )
$value = '';
}
if ( ! $value )
$value = '';
break;

case 'timezone_string':
$allowed_zones = timezone_identifiers_list();
if ( ! in_array( $value, $allowed_zones ) && ! empty( $value ) ) {
$value = get_option( $option ); // Resets option to stored value in the case of failed sanitization
if ( function_exists('add_settings_error') )
add_settings_error('timezone_string', 'invalid_timezone_string', __('The timezone you have entered is not valid. Please select a valid timezone.') );
$error = __( 'The timezone you have entered is not valid. Please select a valid timezone.' );
}
break;

case 'permalink_structure':
case 'category_base':
case 'tag_base':
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
$value = esc_url_raw( $value );
$value = str_replace( 'http://', '', $value );
if ( is_wp_error( $value ) ) {
$error = $value->get_error_message();
} else {
$value = esc_url_raw( $value );
$value = str_replace( 'http://', '', $value );
}
break;

case 'default_role' :
Expand All @@ -3535,13 +3568,24 @@ function sanitize_option( $option, $value ) {
case 'moderation_keys':
case 'blacklist_keys':
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
$value = explode( "\n", $value );
$value = array_filter( array_map( 'trim', $value ) );
$value = array_unique( $value );
$value = implode( "\n", $value );
if ( is_wp_error( $value ) ) {
$error = $value->get_error_message();
} else {
$value = explode( "\n", $value );
$value = array_filter( array_map( 'trim', $value ) );
$value = array_unique( $value );
$value = implode( "\n", $value );
}
break;
}

if ( ! empty( $error ) ) {
$value = get_option( $option );
if ( function_exists( 'add_settings_error' ) ) {
add_settings_error( $option, "invalid_{$option}", $error );
}
}

/**
* Filter an option value following sanitization.
*
Expand Down
16 changes: 14 additions & 2 deletions wp-includes/js/tinymce/plugins/wptextpattern/plugin.js
Expand Up @@ -39,6 +39,14 @@
this.execCommand( 'InsertOrderedList' );
} );

add( /^>\s/, function() {
this.formatter.toggle( 'blockquote' );
} );

add( /^(#{2,6})\s/, function() {
this.formatter.toggle( 'h' + arguments[1].length );
} );

editor.on( 'selectionchange', function() {
canUndo = false;
} );
Expand Down Expand Up @@ -84,7 +92,11 @@
}

tinymce.each( patterns, function( pattern ) {
var replace = text.replace( pattern.regExp, '' );
var args,
replace = text.replace( pattern.regExp, function() {
args = arguments;
return '';
} );

if ( text === replace ) {
return;
Expand All @@ -105,7 +117,7 @@

editor.selection.setCursorLocation( parent );

pattern.callback.apply( editor );
pattern.callback.apply( editor, args );
} );

// We need to wait for native events to be triggered.
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/js/tinymce/plugins/wptextpattern/plugin.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified wp-includes/js/tinymce/wp-tinymce.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion wp-includes/media.php
Expand Up @@ -2312,7 +2312,7 @@ function wp_maybe_load_embeds() {
return;
}

wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube\.com/embed/([^/]+)#i', 'wp_embed_handler_youtube' );
wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube' );

wp_embed_register_handler( 'googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo' );

Expand Down
12 changes: 10 additions & 2 deletions wp-includes/pluggable.php
Expand Up @@ -1260,7 +1260,7 @@ function _wp_sanitize_utf8_in_redirect( $matches ) {
* path. A plugin can therefore set or remove allowed host(s) to or from the
* list.
*
* If the host is not allowed, then the redirect is to wp-admin on the siteurl
* If the host is not allowed, then the redirect defaults to wp-admin on the siteurl
* instead. This prevents malicious redirects which redirect to another host,
* but only used in a few places.
*
Expand All @@ -1271,7 +1271,15 @@ function wp_safe_redirect($location, $status = 302) {
// Need to look at the URL the way it will end up in wp_redirect()
$location = wp_sanitize_redirect($location);

$location = wp_validate_redirect($location, admin_url());
/**
* Filter the redirect fallback URL for when the provided redirect is not safe (local).
*
* @since 4.3.0
*
* @param string $fallback_url The fallback URL to use by default.
* @param int $status The redirect status.
*/
$location = wp_validate_redirect( $location, apply_filters( 'wp_safe_redirect_fallback', admin_url(), $status ) );

wp_redirect($location, $status);
}
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Expand Up @@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-alpha-32784';
$wp_version = '4.3-alpha-32795';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down

0 comments on commit 79dbbab

Please sign in to comment.