Make WordPress Core


Ignore:
Timestamp:
12/17/2024 11:56:28 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Privacy: Use SHA-256 hashing algorithm for Gravatar.

This aims to improve privacy by switching to a more secure algorithm, as an MD5 string can be reversed.

Follow-up to [6748], [31107].

Props henry.wright, jucaduca, haozi, desrosj, dd32, SergeyBiryukov.
See #60638.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/avatar.php

    r58822 r59532  
    1212        public function test_get_avatar_url_gravatar_url() {
    1313                $url = get_avatar_url( 1 );
    14                 $this->assertSame( preg_match( '|^https?://secure.gravatar.com/avatar/[0-9a-f]{32}\?|', $url ), 1 );
     14                $this->assertSame( preg_match( '|^https?://secure.gravatar.com/avatar/[0-9a-f]{64}\?|', $url ), 1 );
    1515        }
    1616
    … …  
    9191                $this->assertSame( $url, $url2 );
    9292
     93                $url2 = get_avatar_url( hash( 'sha256', WP_TESTS_EMAIL ) . '@sha256.gravatar.com' );
     94                $this->assertSame( $url, $url2 );
     95
    9396                $url2 = get_avatar_url( md5( WP_TESTS_EMAIL ) . '@md5.gravatar.com' );
    94                 $this->assertSame( $url, $url2 );
     97                $this->assertSame( preg_match( '|^https?://secure.gravatar.com/avatar/[0-9a-f]{32}\?|', $url2 ), 1 );
    9598
    9699                $user = get_user_by( 'id', 1 );
    … …  
    268271
    269272                $this->assertTrue( is_avatar_comment_type( $comment_type ) );
    270                 $this->assertMatchesRegularExpression( '|^https?://secure.gravatar.com/avatar/[0-9a-f]{32}\?|', $actual_data['url'] );
     273                $this->assertMatchesRegularExpression( '|^https?://secure.gravatar.com/avatar/[0-9a-f]{64}\?|', $actual_data['url'] );
    271274        }
    272275
Note: See TracChangeset for help on using the changeset viewer.