From 965c8cfbe9dfafbabe12036032aef5a543713a9c Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 23 Nov 2015 19:07:46 -0700 Subject: [PATCH] Only generate one nonce per process --- system/src/Grav/Common/Utils.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index 12c3d1026..71a706791 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -15,6 +15,8 @@ abstract class Utils { use GravTrait; + protected static $nonce; + /** * @param string $haystack * @param string $needle @@ -491,9 +493,15 @@ abstract class Utils */ public static function getNonce($action, $plusOneTick = false) { + // Don't regenerate this again if not needed + if (isset(static::$nonce)) { + return static::$nonce; + } $nonce = self::hash(self::generateNonceString($action, $plusOneTick)); - $nonce = str_replace('/', 'SLASH', $nonce); - return $nonce; + + static::$nonce = str_replace('/', 'SLASH', $nonce); + + return static::$nonce; } /**