From: Tim Düsterhus Date: Thu, 3 Jan 2019 12:50:40 +0000 (+0100) Subject: Replace complex generation of random IDs with StringUtil::getRandomID() X-Git-Tag: 5.2.0_Alpha_1~371^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bacec2cfeaf8716581382c566802446bc144cc1b;p=GitHub%2FWoltLab%2FWCF.git Replace complex generation of random IDs with StringUtil::getRandomID() --- 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)); } }