Try to do a better job of matching user agent strings

Bug: T124264
Change-Id: Ieb51d97f46c478ee5527e4bc20a54c6929b54727
This commit is contained in:
Alex Monk 2016-01-22 02:22:34 +00:00
parent f0b2ce2ded
commit f6c2d234be

View file

@ -72,15 +72,19 @@ class VisualEditorHooks {
$blacklist = $config->get( 'VisualEditorBrowserBlacklist' );
$ua = strtolower( $req->getHeader( 'User-Agent' ) );
foreach ( $blacklist as $uaSubstr => $rules ) {
if ( !strpos( $ua, $uaSubstr ) ) {
if ( !strpos( $ua, $uaSubstr . '/' ) ) {
continue;
}
if ( !is_array( $rules ) ) {
return true;
}
$uaParts = preg_split( '/' . $uaSubstr . '\//', $ua ); // PHP 5.3 compat
$version = $uaParts[ 1 ];
$matches = array();
$ret = preg_match( '/' . $uaSubstr . '\/([0-9\.]*) ?/i', $ua, $matches );
if ( $ret !== 1 ) {
continue;
}
$version = $matches[1];
foreach ( $rules as $rule ) {
list( $op, $matchVersion ) = $rule;
if (