Changeset 14307
- Timestamp:
- 12/18/2024 03:14:25 AM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/core/credits/wp-credits.php
r14170 r14307 222 222 continue; 223 223 if ( $user->display_name && $user->display_name != $user->user_nicename && false === strpos( $user->display_name , '?') ) 224 $validators[ $user->user_nicename ] = array( $this->_encode( $user->display_name ), md5( $user->user_email ), $user->user_nicename );224 $validators[ $user->user_nicename ] = array( $this->_encode( $user->display_name ), $this->hash( $user->user_email ), $user->user_nicename ); 225 225 else 226 $validators[ $user->user_nicename ] = array( $user->user_nicename, md5( $user->user_email ), $user->user_nicename );226 $validators[ $user->user_nicename ] = array( $user->user_nicename, $this->hash( $user->user_email ), $user->user_nicename ); 227 227 } 228 228 … … 300 300 301 301 if ( ! empty( $person[2] ) ) { 302 // array( 'Andrew Nacin', 'Lead Developer', ' md5hash' )302 // array( 'Andrew Nacin', 'Lead Developer', 'gravatar hash' ) 303 303 $new_data['title'] = $person[1]; 304 304 $new_data['hash'] = $person[2]; … … 306 306 // array( 'Andrew Nacin' ) 307 307 $fetch_emails_from_user_cache[ $k ] = $group_slug; 308 } elseif ( strlen( $person[1] ) === 32 && preg_match('/^[a-f0-9]{32}$/',$person[1] ) ) {309 // array( 'Andrew Nacin', ' md5hash' )308 } elseif ( $this->is_hashed( $person[1] ) ) { 309 // array( 'Andrew Nacin', 'gravatar hash' ) 310 310 $new_data['hash'] = $person[1]; 311 311 } else { … … 316 316 317 317 // Temporary: 318 if ( strlen( $new_data['hash'] ) != 32 || strpos( $new_data['hash'], '@') ) {319 $new_data['hash'] = md5( $new_data['hash'] );318 if ( ! $this->is_hashed( $new_data['hash'] ) ) { 319 $new_data['hash'] = $this->hash( $new_data['hash'] ); 320 320 } 321 321 … … 331 331 if ( $user_id ) { 332 332 if ( $user_object = wp_cache_get( $user_id, 'users' ) ) { 333 $groups[ $group ]['data'][ $username ][1] = md5( strtolower( $user_object->user_email ));333 $groups[ $group ]['data'][ $username ][1] = $this->hash( $user_object->user_email ); 334 334 } else { 335 335 $fetch_emails_from_db[ $username ] = $group; … … 342 342 $fetched = $wpdb->get_results( "SELECT user_login, ID, user_email FROM $wpdb->users WHERE user_login IN ('" . implode( "', '", array_keys( $fetch_emails_from_db ) ) . "')", OBJECT_K ); 343 343 foreach ( $fetched as $username => $row ) { 344 $groups[ $fetch_emails_from_db[ $username ] ]['data'][ $username ][1] = md5( strtolower( $row->user_email ));344 $groups[ $fetch_emails_from_db[ $username ] ]['data'][ $username ][1] = $this->hash( $row->user_email ); 345 345 wp_cache_add( $username, $row->ID, 'userlogins' ); 346 346 } … … 446 446 } 447 447 448 private function is_hashed( $maybe_hash ) { 449 if ( 450 ! is_string( $maybe_hash ) || 451 strpos( $maybe_hash, '@' ) !== false 452 ) { 453 return false; 454 } 455 456 switch ( strlen( $maybe_hash ) ) { 457 case 32: 458 return preg_match( '/^[a-f0-9]{32}$/', $maybe_hash ); 459 case 64: 460 return preg_match( '/^[a-f0-9]{64}$/', $maybe_hash ); 461 } 462 463 return false; 464 } 465 466 private function hash( $email ) { 467 return hash( 'sha256', strtolower( $email ) ); 468 } 469 448 470 }
Note: See TracChangeset
for help on using the changeset viewer.