Skip to content
Extraits de code Groupes Projets
Valider e66c3d52 rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

refs #6661 also return a HTTP 400 in case there is another invalid request param

parent 03d1687c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Exception;
class InvalidRequestParameterException extends Exception
{
}
\ No newline at end of file
......@@ -12,6 +12,8 @@ use Exception;
use Piwik\Common;
use Piwik\Config;
use Piwik\Cookie;
use Piwik\Exception\InvalidRequestParameterException;
use Piwik\Exception\InvalidVisitorIdException;
use Piwik\Exception\UnexpectedWebsiteFoundException;
use Piwik\IP;
use Piwik\Network\IPUtils;
......@@ -304,7 +306,7 @@ class Request
);
if (!isset($supportedParams[$name])) {
throw new Exception("Requested parameter $name is not a known Tracking API Parameter.");
throw new InvalidRequestParameterException("Requested parameter $name is not a known Tracking API Parameter.");
}
$paramDefaultValue = $supportedParams[$name][0];
......@@ -524,7 +526,7 @@ class Request
$idVisitor = $this->getForcedVisitorId();
if (!empty($idVisitor)) {
if (strlen($idVisitor) != Tracker::LENGTH_HEX_ID_STRING) {
throw new Exception("Visitor ID (cid) $idVisitor must be " . Tracker::LENGTH_HEX_ID_STRING . " characters long");
throw new InvalidRequestParameterException("Visitor ID (cid) $idVisitor must be " . Tracker::LENGTH_HEX_ID_STRING . " characters long");
}
Common::printDebug("Request will be recorded for this idvisitor = " . $idVisitor);
$found = true;
......
......@@ -85,4 +85,13 @@ class TrackerTest extends SystemTestCase
$this->assertResponseCode(400, $url);
}
public function test_response_ShouldSend400ResponseCode_IfInvalidRequestParameterIsGiven()
{
$url = $this->tracker->getUrlTrackPageView('Test');
$url .= '&cid=' . str_pad('1', 16, '1');
$this->assertResponseCode(200, $url);
$this->assertResponseCode(400, $url . '1'); // has to be 16 char, but is 17 now
}
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter