fix predictability and collision

This commit is contained in:
Matthias Pfefferle 2023-07-18 14:36:33 +02:00
parent ee3574a8a3
commit 7b83fddfe0

View file

@ -47,6 +47,10 @@ class Hashtag {
$protect = function( $m ) use ( &$protected_tags ) { $protect = function( $m ) use ( &$protected_tags ) {
$c = \wp_rand( 100000, 999999 ); $c = \wp_rand( 100000, 999999 );
$protect = '!#!#PROTECT' . $c . '#!#!'; $protect = '!#!#PROTECT' . $c . '#!#!';
while ( isset( $protected_tags[ $protect ] ) ) {
$c = \wp_rand( 100000, 999999 );
$protect = '!#!#PROTECT' . $c . '#!#!';
}
$protected_tags[ $protect ] = $m[0]; $protected_tags[ $protect ] = $m[0];
return $protect; return $protect;
}; };