Replace complex generation of random IDs with StringUtil::getRandomID()
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 3 Jan 2019 12:50:40 +0000 (13:50 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 3 Jan 2019 12:50:40 +0000 (13:50 +0100)
wcfsetup/install/files/lib/system/bbcode/MessageParser.class.php
wcfsetup/install/files/lib/system/bbcode/SimpleMessageParser.class.php
wcfsetup/install/files/lib/util/StringStack.class.php
wcfsetup/install/files/lib/util/UserRegistrationUtil.class.php

index fb77f37dc21168fbe4dcf34eb1ba8b75ac64e0e9..1d501e43fccf14789aadcea6812e7f675daf2fab 100644 (file)
@@ -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]);
index 40a788f0f98ab2d739cb02efbe1490c1f79bf260..3e490d5ec53fd23d22366ff7c40bd6c33d2e1f28 100644 (file)
@@ -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;
index 541906829d56af375181f95b234442b857b9038b..228e1797ddce6a3fd7fea005dd59125ff4f8a978 100644 (file)
@@ -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] = [];
index ce51c15c942f25d5d1a0593920ebfaf29e0ef162..0edc3c6257ec11cc543592532eef3da8fa20cb6e 100644 (file)
@@ -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));
        }
 }