Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Winkler <github@lw1.at>2019-04-12 00:15:59 +0300
committerThomas Steur <tsteur@users.noreply.github.com>2019-04-12 00:15:59 +0300
commitd6f49f21514ab84330d1f42ba8f8019749f00406 (patch)
treec86647f37a13065bf1bea98a540255ab36461427 /plugins/PrivacyManager
parent49766472e7d3c658ceae76d8f0f58f7403a2f0f7 (diff)
remove special handling of browsers with DNT enabled by default (#13686)
* remove special handling of browsers with DNT enabled by default * send event to plugins * remove useless lines
Diffstat (limited to 'plugins/PrivacyManager')
-rw-r--r--plugins/PrivacyManager/DoNotTrackHeaderChecker.php47
-rw-r--r--plugins/PrivacyManager/tests/Unit/DoNotTrackHeaderCheckerTest.php33
2 files changed, 6 insertions, 74 deletions
diff --git a/plugins/PrivacyManager/DoNotTrackHeaderChecker.php b/plugins/PrivacyManager/DoNotTrackHeaderChecker.php
index c8c6f9df9b..231eafcffc 100644
--- a/plugins/PrivacyManager/DoNotTrackHeaderChecker.php
+++ b/plugins/PrivacyManager/DoNotTrackHeaderChecker.php
@@ -9,8 +9,8 @@
namespace Piwik\Plugins\PrivacyManager;
use Piwik\Common;
+use Piwik\Piwik;
use Piwik\Tracker\IgnoreCookie;
-use Piwik\Tracker\Request;
/**
* Excludes visits where user agent's request contains either:
@@ -18,7 +18,6 @@ use Piwik\Tracker\Request;
* - X-Do-Not-Track header (used by AdBlockPlus and NoScript)
* - DNT header (used by Mozilla)
*
- * Note: visits from Internet Explorer and other browsers that have DoNoTrack enabled by default will be tracked anyway.
*/
class DoNotTrackHeaderChecker
{
@@ -70,11 +69,11 @@ class DoNotTrackHeaderChecker
return false;
}
- $request = new Request($_REQUEST);
- $userAgent = $request->getUserAgent();
+ $shouldIgnore = false;
- if ($this->isUserAgentWithDoNotTrackAlwaysEnabled($userAgent)) {
- Common::printDebug("INTERNET EXPLORER enable DoNotTrack by default; so Piwik ignores DNT IE browsers...");
+ Piwik::postEvent('PrivacyManager.shouldIgnoreDnt', array(&$shouldIgnore));
+ if($shouldIgnore) {
+ Common::printDebug("DoNotTrack header ignored by Matomo because of a plugin");
return false;
}
@@ -116,40 +115,4 @@ class DoNotTrackHeaderChecker
return (isset($_SERVER['HTTP_X_DO_NOT_TRACK']) && $_SERVER['HTTP_X_DO_NOT_TRACK'] === '1')
|| (isset($_SERVER['HTTP_DNT']) && substr($_SERVER['HTTP_DNT'], 0, 1) === '1');
}
-
- /**
- *
- * @param $userAgent
- * @return bool
- */
- protected function isUserAgentWithDoNotTrackAlwaysEnabled($userAgent)
- {
- $browsersWithDnt = $this->getBrowsersWithDNTAlwaysEnabled();
- foreach($browsersWithDnt as $userAgentBrowserFragment) {
- if (stripos($userAgent, $userAgentBrowserFragment) !== false) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Some browsers have DNT enabled by default. For those we will ignore DNT and always track those users.
- *
- * @return array
- */
- protected function getBrowsersWithDNTAlwaysEnabled()
- {
- return array(
- // IE
- 'MSIE',
- 'Trident',
-
- // Maxthon
- 'Maxthon',
-
- // Epiphany - https://github.com/piwik/piwik/issues/8682
- 'Epiphany',
- );
- }
}
diff --git a/plugins/PrivacyManager/tests/Unit/DoNotTrackHeaderCheckerTest.php b/plugins/PrivacyManager/tests/Unit/DoNotTrackHeaderCheckerTest.php
index a0bf82e958..e17dcc8815 100644
--- a/plugins/PrivacyManager/tests/Unit/DoNotTrackHeaderCheckerTest.php
+++ b/plugins/PrivacyManager/tests/Unit/DoNotTrackHeaderCheckerTest.php
@@ -80,37 +80,6 @@ class DoNotTrackHeaderCheckerTest extends \PHPUnit_Framework_TestCase
$this->assertFalse( $dntChecker->isDoNotTrackFound() );
}
- public function getUserAgents_whereDNTIsAlwaysEnabled()
- {
- return array(
- // IE
- array('Mozilla/4.0 (compatible; MSIE 4.01; Mac_PowerPC)'),
- array('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.4; OfficeLivePatch.1.3)'),
- array('Mozilla/5.0 (IE 11.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C; rv:11.0) like Gecko'),
-
- // Maxthon
- array('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; MAXTHON 2.0)'),
- array('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Maxthon/4.2.0.4000)'),
- array('Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Maxthon/4.4.3.1000 Chrome/30.0.1599.101 Safari/537.36'),
-
- // With capital letters
- array('Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) MAXTHON/4.4.3.1000 Chrome/30.0.1599.101 Safari/537.36'),
- );
- }
-
- /**
- * @dataProvider getUserAgents_whereDNTIsAlwaysEnabled
- */
- public function test_isDoNotTrackFound_whenDntActivated_InternetExplorerDoNotTrackIsIgnored($userAgent)
- {
- $dntChecker = $this->makeDntHeaderCheckerEnabled();
-
- $this->activateDoNotTrackInBrowser();
-
- $_SERVER['HTTP_USER_AGENT'] = $userAgent;
- $this->assertFalse($dntChecker->isDoNotTrackFound());
- }
-
/**
* @return Config
*/
@@ -162,4 +131,4 @@ class DoNotTrackHeaderCheckerTest extends \PHPUnit_Framework_TestCase
$_SERVER['HTTP_DNT'] = '1';
}
}
- \ No newline at end of file
+