Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.6/wp-includes/functions.php

    r24918 r25345  
    243243 *
    244244 * @param mixed $data Value to check to see if was serialized.
     245 * @param bool $strict Optional. Whether to be strict about the end of the string. Defaults true.
    245246 * @return bool False if not serialized and true if it was.
    246247 */
    247 function is_serialized( $data ) {
     248function is_serialized( $data, $strict = true ) {
    248249    // if it isn't a string, it isn't serialized
    249250    if ( ! is_string( $data ) )
     
    257258    if ( ':' !== $data[1] )
    258259        return false;
    259     $lastc = $data[$length-1];
    260     if ( ';' !== $lastc && '}' !== $lastc )
    261         return false;
     260    if ( $strict ) {
     261        $lastc = $data[ $length - 1 ];
     262        if ( ';' !== $lastc && '}' !== $lastc )
     263            return false;
     264    } else {
     265        $semicolon = strpos( $data, ';' );
     266        $brace     = strpos( $data, '}' );
     267        // Either ; or } must exist.
     268        if ( false === $semicolon && false === $brace )
     269            return false;
     270        // But neither must be in the first X characters.
     271        if ( false !== $semicolon && $semicolon < 3 )
     272            return false;
     273        if ( false !== $brace && $brace < 4 )
     274            return false;
     275    }
    262276    $token = $data[0];
    263277    switch ( $token ) {
    264278        case 's' :
    265             if ( '"' !== $data[$length-2] )
     279            if ( $strict ) {
     280                if ( '"' !== $data[ $length - 2 ] )
     281                    return false;
     282            } elseif ( false === strpos( $data, '"' ) ) {
    266283                return false;
     284            }
    267285        case 'a' :
    268286        case 'O' :
     
    271289        case 'i' :
    272290        case 'd' :
    273             return (bool) preg_match( "/^{$token}:[0-9.E-]+;\$/", $data );
     291            $end = $strict ? '$' : '';
     292            return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data );
    274293    }
    275294    return false;
     
    318337    // Double serialization is required for backward compatibility.
    319338    // See http://core.trac.wordpress.org/ticket/12930
    320     if ( is_serialized( $data ) )
     339    if ( is_serialized( $data, false ) )
    321340        return serialize( $data );
    322341
     
    12841303
    12851304    if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) )
    1286         return wp_unslash( $ref );
     1305        return wp_validate_redirect( $ref, false );
    12871306    return false;
    12881307}
     
    12991318function wp_get_original_referer() {
    13001319    if ( !empty( $_REQUEST['_wp_original_http_referer'] ) )
    1301         return wp_unslash( $_REQUEST['_wp_original_http_referer'] );
     1320        return wp_validate_redirect( wp_unslash( $_REQUEST['_wp_original_http_referer'] ), false );
    13021321    return false;
    13031322}
     
    20072026 * @uses wp_get_upload_mime_types() to fetch the list of mime types
    20082027 *
     2028 * @param int|WP_User $user Optional. User to check. Defaults to current user.
    20092029 * @return array Array of mime types keyed by the file extension regex corresponding to those types.
    20102030 */
    2011 function get_allowed_mime_types() {
    2012     return apply_filters( 'upload_mimes', wp_get_mime_types() );
     2031function get_allowed_mime_types( $user = null ) {
     2032    $t = wp_get_mime_types();
     2033
     2034    unset( $t['swf'], $t['exe'] );
     2035    if ( function_exists( 'current_user_can' ) )
     2036        $unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' );
     2037
     2038    if ( empty( $unfiltered ) )
     2039        unset( $t['htm|html'] );
     2040
     2041    return apply_filters( 'upload_mimes', $t, $user );
    20132042}
    20142043
Note: See TracChangeset for help on using the changeset viewer.