From 8f36db0be5fa1de82a2ad14932d85d4f23a0ca3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Thu, 19 Nov 2015 14:14:16 +0100 Subject: [PATCH] MDL-52214 core: Fix case sensitivity in user agent comparison The previous 2.9 implementation of is_web_crawler() used stripos() in certain cases. The unit tests re-added in the previous commit revealed that certain crawlers (such as BaiDuSpider) were not correctly detected in the new refactored implementation. It seems lesser evil and safe enough to use /i in the regex search even though it is not 100% same logic as before - as stripos() was used in some cases only, not always. --- lib/classes/useragent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/classes/useragent.php b/lib/classes/useragent.php index 5ed0c7311bd..b62cf419e70 100644 --- a/lib/classes/useragent.php +++ b/lib/classes/useragent.php @@ -215,7 +215,7 @@ class core_useragent { * @return bool */ protected function is_useragent_web_crawler() { - $regex = '/Googlebot|google\.com|Yahoo! Slurp|\[ZSEBOT\]|msnbot|bingbot|BingPreview|Yandex|AltaVista|Baiduspider|Teoma/'; + $regex = '/Googlebot|google\.com|Yahoo! Slurp|\[ZSEBOT\]|msnbot|bingbot|BingPreview|Yandex|AltaVista|Baiduspider|Teoma/i'; return (preg_match($regex, $this->useragent)); }