Skip to content

Commit

Permalink
Safari can appear in iPad, iPod, iPhone and future Apple products, it…
Browse files Browse the repository at this point in the history
… is not fair to attach it to one of them.
  • Loading branch information
marcosgdf committed Feb 23, 2015
1 parent 102d2d9 commit 71b98ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions htdocs/core/lib/functions.lib.php
Expand Up @@ -165,8 +165,7 @@ function getBrowserInfo($user_agent)
elseif (preg_match('/chrome/i', $user_agent, $reg)) { $name='chrome'; }
elseif (preg_match('/iceweasel/i', $user_agent)) { $name='iceweasel'; $version=$reg[2]; }
elseif (preg_match('/epiphany/i', $user_agent)) { $name='epiphany'; $version=$reg[2]; }
elseif ((empty($phone) || preg_match('/iphone/i', $user_agent)) && preg_match('/safari(\/|\s)([\d\.]*)/i',
$user_agent, $reg)) { $name='safari'; $version=$reg[2]; } // Safari is often present in string for mobile but its not.
elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='safari'; $version=$reg[2]; } // Safari is often present in string for mobile but its not.
elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='opera'; $version=$reg[2]; }
elseif (preg_match('/msie(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='ie'; $version=$reg[2]; } // MS products at end

Expand Down
6 changes: 6 additions & 0 deletions test/phpunit/FunctionsLibTest.php
Expand Up @@ -163,6 +163,12 @@ public function testGetBrowserInfo()
$tmp=getBrowserInfo($user_agent);
$this->assertEquals('ie',$tmp['browsername']);
$this->assertEquals('11.0',$tmp['browserversion']);

//iPad
$user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25';
$tmp=getBrowserInfo($user_agent);
$this->assertEquals('ie',$tmp['browsername']);
$this->assertEquals('11.0',$tmp['browserversion']);
}


Expand Down

0 comments on commit 71b98ee

Please sign in to comment.