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:
Diffstat (limited to 'core/Tracker/VisitExcluded.php')
-rw-r--r--core/Tracker/VisitExcluded.php9
1 files changed, 7 insertions, 2 deletions
diff --git a/core/Tracker/VisitExcluded.php b/core/Tracker/VisitExcluded.php
index 243618bc51..8d412cef26 100644
--- a/core/Tracker/VisitExcluded.php
+++ b/core/Tracker/VisitExcluded.php
@@ -349,12 +349,13 @@ class VisitExcluded
* Returns true if the specified user agent should be excluded for the current site or not.
*
* Visits whose user agent string contains one of the excluded_user_agents strings for the
- * site being tracked (or one of the global strings) will be excluded.
+ * site being tracked (or one of the global strings) will be excluded. Regular expressions
+ * are also supported.
*
* @internal param string $this ->userAgent The user agent string.
* @return bool
*/
- protected function isUserAgentExcluded()
+ protected function isUserAgentExcluded(): bool
{
$excludedAgents = $this->getAttributes('excluded_user_agents', 'global_excluded_user_agents');
@@ -364,6 +365,10 @@ class VisitExcluded
if (stripos($this->userAgent, $excludedUserAgent) !== false) {
return true;
}
+ // if the string is a valid regex, and the user agent matches, this visit should be excluded
+ if (@preg_match($excludedUserAgent, null) !== false) {
+ return preg_match($excludedUserAgent, $this->userAgent) ? true : false;
+ }
}
}