Handle multiple nonce action types per page

This commit is contained in:
Flavio Copes
2015-11-24 09:03:48 +01:00
parent 965c8cfbe9
commit 583156d2f3

View File

@@ -15,7 +15,7 @@ abstract class Utils
{
use GravTrait;
protected static $nonce;
protected static $nonces = [];
/**
* @param string $haystack
@@ -494,14 +494,14 @@ 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;
if (isset(static::$nonces[$action])) {
return static::$nonces[$action];
}
$nonce = self::hash(self::generateNonceString($action, $plusOneTick));
static::$nonce = str_replace('/', 'SLASH', $nonce);
static::$nonces[$action] = str_replace('/', 'SLASH', $nonce);
return static::$nonce;
return static::$nonces[$action];
}
/**