mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-18 09:10:59 +00:00
Try to do a better job of matching user agent strings
Bug: T124264 Change-Id: Ieb51d97f46c478ee5527e4bc20a54c6929b54727
This commit is contained in:
parent
f0b2ce2ded
commit
f6c2d234be
|
@ -72,15 +72,19 @@ class VisualEditorHooks {
|
||||||
$blacklist = $config->get( 'VisualEditorBrowserBlacklist' );
|
$blacklist = $config->get( 'VisualEditorBrowserBlacklist' );
|
||||||
$ua = strtolower( $req->getHeader( 'User-Agent' ) );
|
$ua = strtolower( $req->getHeader( 'User-Agent' ) );
|
||||||
foreach ( $blacklist as $uaSubstr => $rules ) {
|
foreach ( $blacklist as $uaSubstr => $rules ) {
|
||||||
if ( !strpos( $ua, $uaSubstr ) ) {
|
if ( !strpos( $ua, $uaSubstr . '/' ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( !is_array( $rules ) ) {
|
if ( !is_array( $rules ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uaParts = preg_split( '/' . $uaSubstr . '\//', $ua ); // PHP 5.3 compat
|
$matches = array();
|
||||||
$version = $uaParts[ 1 ];
|
$ret = preg_match( '/' . $uaSubstr . '\/([0-9\.]*) ?/i', $ua, $matches );
|
||||||
|
if ( $ret !== 1 ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$version = $matches[1];
|
||||||
foreach ( $rules as $rule ) {
|
foreach ( $rules as $rule ) {
|
||||||
list( $op, $matchVersion ) = $rule;
|
list( $op, $matchVersion ) = $rule;
|
||||||
if (
|
if (
|
||||||
|
|
Loading…
Reference in a new issue