From bacec2cfeaf8716581382c566802446bc144cc1b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 3 Jan 2019 13:50:40 +0100 Subject: [PATCH] Replace complex generation of random IDs with StringUtil::getRandomID() --- .../install/files/lib/system/bbcode/MessageParser.class.php | 2 +- .../files/lib/system/bbcode/SimpleMessageParser.class.php | 4 ++-- wcfsetup/install/files/lib/util/StringStack.class.php | 2 +- .../install/files/lib/util/UserRegistrationUtil.class.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/lib/system/bbcode/MessageParser.class.php b/wcfsetup/install/files/lib/system/bbcode/MessageParser.class.php index fb77f37dc2..1d501e43fc 100644 --- a/wcfsetup/install/files/lib/system/bbcode/MessageParser.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/MessageParser.class.php @@ -168,7 +168,7 @@ class MessageParser extends BBCodeParser { */ protected function cacheCodesCallback($matches) { // create hash - $hash = '@@'.StringUtil::getHash(uniqid(microtime()).$matches[3]).'@@'; + $hash = '@@'.StringUtil::getRandomID().'@@'; // build tag $tag = $this->buildTag($matches[1]); diff --git a/wcfsetup/install/files/lib/system/bbcode/SimpleMessageParser.class.php b/wcfsetup/install/files/lib/system/bbcode/SimpleMessageParser.class.php index 40a788f0f9..3e490d5ec5 100644 --- a/wcfsetup/install/files/lib/system/bbcode/SimpleMessageParser.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/SimpleMessageParser.class.php @@ -169,7 +169,7 @@ class SimpleMessageParser extends SingletonFactory { * @return string */ protected function cacheURLsCallback($matches) { - $hash = '@@'.StringUtil::getHash(uniqid(microtime()).$matches[0]).'@@'; + $hash = '@@'.StringUtil::getRandomID().'@@'; $this->cachedURLs[$hash] = $matches[0]; return $hash; @@ -182,7 +182,7 @@ class SimpleMessageParser extends SingletonFactory { * @return string */ protected function cacheEmailsCallback($matches) { - $hash = '@@'.StringUtil::getHash(uniqid(microtime()).$matches[0]).'@@'; + $hash = '@@'.StringUtil::getRandomID().'@@'; $this->cachedEmails[$hash] = $matches[0]; return $hash; diff --git a/wcfsetup/install/files/lib/util/StringStack.class.php b/wcfsetup/install/files/lib/util/StringStack.class.php index 541906829d..228e1797dd 100644 --- a/wcfsetup/install/files/lib/util/StringStack.class.php +++ b/wcfsetup/install/files/lib/util/StringStack.class.php @@ -32,7 +32,7 @@ final class StringStack { */ public static function pushToStringStack($string, $type = 'default', $delimiter = '@@') { self::$i++; - $hash = $delimiter.StringUtil::getHash(self::$i.uniqid(microtime()).$string).$delimiter; + $hash = $delimiter.StringUtil::getRandomID().$delimiter; if (!isset(self::$stringStack[$type])) { self::$stringStack[$type] = []; diff --git a/wcfsetup/install/files/lib/util/UserRegistrationUtil.class.php b/wcfsetup/install/files/lib/util/UserRegistrationUtil.class.php index ce51c15c94..0edc3c6257 100644 --- a/wcfsetup/install/files/lib/util/UserRegistrationUtil.class.php +++ b/wcfsetup/install/files/lib/util/UserRegistrationUtil.class.php @@ -142,7 +142,7 @@ final class UserRegistrationUtil { * @return string */ public static function getRandomFieldName($fieldName) { - $hash = StringUtil::getHash($fieldName . StringUtil::getRandomID()); + $hash = StringUtil::getRandomID(); return substr($hash, 0, mt_rand(8, 16)); } } -- 2.20.1