Skip to content
Extraits de code Groupes Projets
Valider 5e3f188f rédigé par mattab's avatar mattab
Parcourir les fichiers

For Outlinks and Download URLs, do not exclude URL parameters and store URLs untouched

Also adds a missing URL Encoding for action URLs.
(when outlink or download urls contained `&` and such characters breaking the URL this possibly corrupted the tracking request).

Fixes #6244
parent fe3e5ec3
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 74 ajouts et 40 suppressions
...@@ -206,6 +206,12 @@ abstract class Action ...@@ -206,6 +206,12 @@ abstract class Action
} }
} }
protected function setActionUrlWithoutExcludingParameters($url)
{
$this->rawActionUrl = PageUrl::getUrlIfLookValid($url);
$this->actionUrl = PageUrl::getUrlIfLookValid($url);
}
abstract protected function getActionsToLookup(); abstract protected function getActionsToLookup();
protected function getUrlAndType() protected function getUrlAndType()
......
...@@ -24,7 +24,7 @@ class ActionClickUrl extends Action ...@@ -24,7 +24,7 @@ class ActionClickUrl extends Action
public function __construct(Request $request) public function __construct(Request $request)
{ {
parent::__construct(self::TYPE_OUTLINK, $request); parent::__construct(self::TYPE_OUTLINK, $request);
$this->setActionUrl($request->getParam('link')); $this->setActionUrlWithoutExcludingParameters($request->getParam('link'));
} }
public static function shouldHandle(Request $request) public static function shouldHandle(Request $request)
......
...@@ -20,7 +20,7 @@ class ActionDownloadUrl extends Action ...@@ -20,7 +20,7 @@ class ActionDownloadUrl extends Action
public function __construct(Request $request) public function __construct(Request $request)
{ {
parent::__construct(self::TYPE_DOWNLOAD, $request); parent::__construct(self::TYPE_DOWNLOAD, $request);
$this->setActionUrl($request->getParam('download')); $this->setActionUrlWithoutExcludingParameters($request->getParam('download'));
} }
public static function shouldHandle(Request $request) public static function shouldHandle(Request $request)
......
...@@ -603,7 +603,12 @@ class ArchivingHelper ...@@ -603,7 +603,12 @@ class ArchivingHelper
$urlFragment = $matches[3]; $urlFragment = $matches[3];
if (in_array($type, array(Action::TYPE_DOWNLOAD, Action::TYPE_OUTLINK))) { if (in_array($type, array(Action::TYPE_DOWNLOAD, Action::TYPE_OUTLINK))) {
return array(trim($urlHost), '/' . trim($urlPath)); $path = '/' . trim($urlPath);
if (!empty($urlFragment)) {
$path .= '#' . $urlFragment;
}
return array(trim($urlHost), $path);
} }
$name = $urlPath; $name = $urlPath;
......
...@@ -106,7 +106,9 @@ class OneVisitorTwoVisits extends Fixture ...@@ -106,7 +106,9 @@ class OneVisitorTwoVisits extends Fixture
// Click on external link after 6 minutes (3rd action) // Click on external link after 6 minutes (3rd action)
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.1)->getDatetime()); $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.1)->getDatetime());
self::checkResponse($t->doTrackAction('http://dev.piwik.org/svn', 'link'));
// Testing Outlink that contains a URL Fragment
self::checkResponse($t->doTrackAction('https://outlinks.org/#!outlink-with-fragment-<script>', 'link'));
// Click on file download after 12 minutes (4th action) // Click on file download after 12 minutes (4th action)
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.2)->getDatetime()); $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.2)->getDatetime());
...@@ -114,7 +116,7 @@ class OneVisitorTwoVisits extends Fixture ...@@ -114,7 +116,7 @@ class OneVisitorTwoVisits extends Fixture
// Click on two more external links, one the same as before (5th & 6th actions) // Click on two more external links, one the same as before (5th & 6th actions)
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.22)->getDateTime()); $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.22)->getDateTime());
self::checkResponse($t->doTrackAction('http://outlinks.org/other_outlink', 'link')); self::checkResponse($t->doTrackAction('http://outlinks.org/other_outlink#fragment&pk_campaign=Open%20partnership', 'link'));
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.25)->getDateTime()); $t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.25)->getDateTime());
self::checkResponse($t->doTrackAction('http://dev.piwik.org/svn', 'link')); self::checkResponse($t->doTrackAction('http://dev.piwik.org/svn', 'link'));
......
...@@ -124,6 +124,11 @@ class BackwardsCompatibility1XTest extends SystemTestCase ...@@ -124,6 +124,11 @@ class BackwardsCompatibility1XTest extends SystemTestCase
// the Action.getPageTitles test fails for unknown reason, so skipping it // the Action.getPageTitles test fails for unknown reason, so skipping it
// eg. https://travis-ci.org/piwik/piwik/jobs/24449365 // eg. https://travis-ci.org/piwik/piwik/jobs/24449365
'Action.getPageTitles', 'Action.getPageTitles',
// Outlinks now tracked with URL Fragment which was not the case in 1.X
'Actions.get',
'Actions.getOutlink',
'Actions.getOutlinks',
); );
$apiNotToCall = array_merge($apiNotToCall, $reportsToCompareSeparately); $apiNotToCall = array_merge($apiNotToCall, $reportsToCompareSeparately);
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
<label>/svn</label> <label>/svn</label>
<nb_visits>1</nb_visits> <nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors> <nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>2</nb_hits> <nb_hits>1</nb_hits>
<sum_time_spent>540</sum_time_spent> <sum_time_spent>180</sum_time_spent>
<url>http://dev.piwik.org/svn</url> <url>http://dev.piwik.org/svn</url>
</row> </row>
</result> </result>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<result> <result>
<row> <row>
<label>dev.piwik.org</label> <label>outlinks.org</label>
<nb_visits>1</nb_visits> <nb_visits>2</nb_visits>
<nb_hits>2</nb_hits> <nb_hits>2</nb_hits>
<sum_time_spent>540</sum_time_spent> <sum_time_spent>468</sum_time_spent>
<subtable> <subtable>
<row> <row>
<label>/svn</label> <label>/#!outlink-with-fragment-&lt;script&gt;</label>
<nb_visits>1</nb_visits> <nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors> <nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>2</nb_hits> <nb_hits>1</nb_hits>
<sum_time_spent>540</sum_time_spent> <sum_time_spent>360</sum_time_spent>
<url>http://dev.piwik.org/svn</url> <url>https://outlinks.org/#!outlink-with-fragment-&lt;script&gt;</url>
</row>
<row>
<label>/other_outlink#fragment&amp;pk_campaign=Open partnership</label>
<nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>1</nb_hits>
<sum_time_spent>108</sum_time_spent>
<url>http://outlinks.org/other_outlink#fragment&amp;pk_campaign=Open%20partnership</url>
</row> </row>
</subtable> </subtable>
</row> </row>
<row> <row>
<label>outlinks.org</label> <label>dev.piwik.org</label>
<nb_visits>1</nb_visits> <nb_visits>1</nb_visits>
<nb_hits>1</nb_hits> <nb_hits>1</nb_hits>
<sum_time_spent>108</sum_time_spent> <sum_time_spent>180</sum_time_spent>
<subtable> <subtable>
<row> <row>
<label>/other_outlink</label> <label>/svn</label>
<nb_visits>1</nb_visits> <nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors> <nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>1</nb_hits> <nb_hits>1</nb_hits>
<sum_time_spent>108</sum_time_spent> <sum_time_spent>180</sum_time_spent>
<url>http://outlinks.org/other_outlink</url> <url>http://dev.piwik.org/svn</url>
</row> </row>
</subtable> </subtable>
</row> </row>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<nb_downloads>1</nb_downloads> <nb_downloads>1</nb_downloads>
<nb_uniq_downloads>1</nb_uniq_downloads> <nb_uniq_downloads>1</nb_uniq_downloads>
<nb_outlinks>3</nb_outlinks> <nb_outlinks>3</nb_outlinks>
<nb_uniq_outlinks>2</nb_uniq_outlinks> <nb_uniq_outlinks>3</nb_uniq_outlinks>
<nb_searches>0</nb_searches> <nb_searches>0</nb_searches>
<nb_keywords>0</nb_keywords> <nb_keywords>0</nb_keywords>
<avg_time_generation>0.155</avg_time_generation> <avg_time_generation>0.155</avg_time_generation>
......
Le fichier a été supprimé par une entrée .gitattributes, ou son encodage n'est pas pris en charge.
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
<label>/svn</label> <label>/svn</label>
<nb_visits>1</nb_visits> <nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors> <nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>2</nb_hits> <nb_hits>1</nb_hits>
<sum_time_spent>432</sum_time_spent> <sum_time_spent>72</sum_time_spent>
<url>http://dev.piwik.org/svn</url> <url>http://dev.piwik.org/svn</url>
</row> </row>
</result> </result>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<result> <result>
<row> <row>
<label>dev.piwik.org</label> <label>outlinks.org</label>
<nb_visits>1</nb_visits> <nb_visits>2</nb_visits>
<nb_hits>2</nb_hits> <nb_hits>2</nb_hits>
<sum_time_spent>432</sum_time_spent> <sum_time_spent>468</sum_time_spent>
<subtable> <subtable>
<row> <row>
<label>/svn</label> <label>/#!outlink-with-fragment-&lt;script&gt;</label>
<nb_visits>1</nb_visits> <nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors> <nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>2</nb_hits> <nb_hits>1</nb_hits>
<sum_time_spent>432</sum_time_spent> <sum_time_spent>360</sum_time_spent>
<url>http://dev.piwik.org/svn</url> <url>https://outlinks.org/#!outlink-with-fragment-&lt;script&gt;</url>
</row>
<row>
<label>/other_outlink#fragment&amp;pk_campaign=Open partnership</label>
<nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>1</nb_hits>
<sum_time_spent>108</sum_time_spent>
<url>http://outlinks.org/other_outlink#fragment&amp;pk_campaign=Open%20partnership</url>
</row> </row>
</subtable> </subtable>
</row> </row>
<row> <row>
<label>outlinks.org</label> <label>dev.piwik.org</label>
<nb_visits>1</nb_visits> <nb_visits>1</nb_visits>
<nb_hits>1</nb_hits> <nb_hits>1</nb_hits>
<sum_time_spent>108</sum_time_spent> <sum_time_spent>72</sum_time_spent>
<subtable> <subtable>
<row> <row>
<label>/other_outlink</label> <label>/svn</label>
<nb_visits>1</nb_visits> <nb_visits>1</nb_visits>
<nb_uniq_visitors>1</nb_uniq_visitors> <nb_uniq_visitors>1</nb_uniq_visitors>
<nb_hits>1</nb_hits> <nb_hits>1</nb_hits>
<sum_time_spent>108</sum_time_spent> <sum_time_spent>72</sum_time_spent>
<url>http://outlinks.org/other_outlink</url> <url>http://dev.piwik.org/svn</url>
</row> </row>
</subtable> </subtable>
</row> </row>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<nb_downloads>1</nb_downloads> <nb_downloads>1</nb_downloads>
<nb_uniq_downloads>1</nb_uniq_downloads> <nb_uniq_downloads>1</nb_uniq_downloads>
<nb_outlinks>3</nb_outlinks> <nb_outlinks>3</nb_outlinks>
<nb_uniq_outlinks>2</nb_uniq_outlinks> <nb_uniq_outlinks>3</nb_uniq_outlinks>
<nb_searches>1</nb_searches> <nb_searches>1</nb_searches>
<nb_keywords>1</nb_keywords> <nb_keywords>1</nb_keywords>
<avg_time_generation>0.155</avg_time_generation> <avg_time_generation>0.155</avg_time_generation>
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<type>action</type> <type>action</type>
<url>http://example.org/store/purchase.htm</url> <url>http://example.org/store/purchase.htm</url>
<pageTitle>Checkout/Purchasing...</pageTitle> <pageTitle>Checkout/Purchasing...</pageTitle>
<pageIdAction>12</pageIdAction> <pageIdAction>13</pageIdAction>
<pageId>9</pageId> <pageId>9</pageId>
<generationTime>0.13s</generationTime> <generationTime>0.13s</generationTime>
...@@ -147,7 +147,7 @@ ...@@ -147,7 +147,7 @@
</row> </row>
<row> <row>
<type>outlink</type> <type>outlink</type>
<url>http://dev.piwik.org/svn</url> <url>https://outlinks.org/#!outlink-with-fragment-&lt;script&gt;</url>
<pageTitle /> <pageTitle />
<pageIdAction>5</pageIdAction> <pageIdAction>5</pageIdAction>
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
</row> </row>
<row> <row>
<type>outlink</type> <type>outlink</type>
<url>http://outlinks.org/other_outlink</url> <url>http://outlinks.org/other_outlink#fragment&amp;pk_campaign=Open%20partnership</url>
<pageTitle /> <pageTitle />
<pageIdAction>7</pageIdAction> <pageIdAction>7</pageIdAction>
...@@ -185,7 +185,7 @@ ...@@ -185,7 +185,7 @@
<type>outlink</type> <type>outlink</type>
<url>http://dev.piwik.org/svn</url> <url>http://dev.piwik.org/svn</url>
<pageTitle /> <pageTitle />
<pageIdAction>5</pageIdAction> <pageIdAction>8</pageIdAction>
<pageId>6</pageId> <pageId>6</pageId>
<timeSpent>72</timeSpent> <timeSpent>72</timeSpent>
...@@ -221,7 +221,7 @@ ...@@ -221,7 +221,7 @@
<type>action</type> <type>action</type>
<url>http://example.org/index.htm</url> <url>http://example.org/index.htm</url>
<pageTitle>Looking at homepage after site search...</pageTitle> <pageTitle>Looking at homepage after site search...</pageTitle>
<pageIdAction>10</pageIdAction> <pageIdAction>11</pageIdAction>
<pageId>8</pageId> <pageId>8</pageId>
<generationTime>0.02s</generationTime> <generationTime>0.02s</generationTime>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter