private function getPluginNameIfNonceValid($nonceName) { $nonce = Common::getRequestVar('nonce', null, 'string'); if (!Nonce::verifyNonce($nonceName, $nonce)) { throw new \Exception(Piwik::translate('General_ExceptionNonceMismatch')); } Nonce::discardNonce($nonceName); $pluginName = Common::getRequestVar('pluginName', null, 'string'); if (!$this->pluginManager->isValidPluginName($pluginName)) { throw new Exception('Invalid plugin name'); } return $pluginName; }
protected function initPluginModification($nonceName) { Piwik::checkUserHasSuperUserAccess(); $nonce = Common::getRequestVar('nonce', null, 'string'); if (!Nonce::verifyNonce($nonceName, $nonce)) { throw new \Exception($this->translator->translate('General_ExceptionNonceMismatch')); } Nonce::discardNonce($nonceName); $pluginName = Common::getRequestVar('pluginName', null, 'string'); if (!$this->pluginManager->isValidPluginName($pluginName)) { throw new Exception('Invalid plugin name'); } return $pluginName; }
/** * @dataProvider getPluginNameProvider */ public function test_isValidPluginName($expectedIsValid, $pluginName) { $valid = $this->manager->isValidPluginName($pluginName); $this->assertSame($expectedIsValid, $valid); }