- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.6/wp-includes/functions.php
r24918 r25345 243 243 * 244 244 * @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. 245 246 * @return bool False if not serialized and true if it was. 246 247 */ 247 function is_serialized( $data ) {248 function is_serialized( $data, $strict = true ) { 248 249 // if it isn't a string, it isn't serialized 249 250 if ( ! is_string( $data ) ) … … 257 258 if ( ':' !== $data[1] ) 258 259 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 } 262 276 $token = $data[0]; 263 277 switch ( $token ) { 264 278 case 's' : 265 if ( '"' !== $data[$length-2] ) 279 if ( $strict ) { 280 if ( '"' !== $data[ $length - 2 ] ) 281 return false; 282 } elseif ( false === strpos( $data, '"' ) ) { 266 283 return false; 284 } 267 285 case 'a' : 268 286 case 'O' : … … 271 289 case 'i' : 272 290 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 ); 274 293 } 275 294 return false; … … 318 337 // Double serialization is required for backward compatibility. 319 338 // See http://core.trac.wordpress.org/ticket/12930 320 if ( is_serialized( $data ) )339 if ( is_serialized( $data, false ) ) 321 340 return serialize( $data ); 322 341 … … 1284 1303 1285 1304 if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) ) 1286 return wp_ unslash( $ref);1305 return wp_validate_redirect( $ref, false ); 1287 1306 return false; 1288 1307 } … … 1299 1318 function wp_get_original_referer() { 1300 1319 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 ); 1302 1321 return false; 1303 1322 } … … 2007 2026 * @uses wp_get_upload_mime_types() to fetch the list of mime types 2008 2027 * 2028 * @param int|WP_User $user Optional. User to check. Defaults to current user. 2009 2029 * @return array Array of mime types keyed by the file extension regex corresponding to those types. 2010 2030 */ 2011 function get_allowed_mime_types() { 2012 return apply_filters( 'upload_mimes', wp_get_mime_types() ); 2031 function 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 ); 2013 2042 } 2014 2043
Note: See TracChangeset
for help on using the changeset viewer.