Skip to content

Commit

Permalink
MDL-52214 core: Fix case sensitivity in user agent comparison
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mudrd8mz committed Nov 23, 2015
1 parent 182d999 commit ade03c0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/classes/useragent.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ protected function is_useragent_tablet() {
* @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));
}

Expand Down

0 comments on commit ade03c0

Please sign in to comment.