Permalink
Browse files

MDL-34446 Fix bugs in previous commit

  • Loading branch information...
1 parent dc5d4f4 commit 1d075eadd9cb829e4897f5f7bca6e930a69230da @sammarshallou sammarshallou committed with danpoltawski Aug 15, 2012
Showing with 11 additions and 4 deletions.
  1. +11 −4 lib/moodlelib.php
View
@@ -8369,7 +8369,14 @@ function check_browser_version($brand, $version = null) {
if (empty($version)) {
return true; // no version specified
}
- if (preg_match("/Opera\/([0-9\.]+)/i", $agent, $match)) {
+ // Recent Opera useragents have Version/ with the actual version, e.g.:
+ // Opera/9.80 (Windows NT 6.1; WOW64; U; en) Presto/2.10.289 Version/12.01
+ // That's Opera 12.01, not 9.8.
+ if (preg_match("/Version\/([0-9\.]+)/i", $agent, $match)) {
+ if (version_compare($match[1], $version) >= 0) {
+ return true;
+ }
+ } else if (preg_match("/Opera\/([0-9\.]+)/i", $agent, $match)) {
if (version_compare($match[1], $version) >= 0) {
return true;
}
@@ -8384,7 +8391,7 @@ function check_browser_version($brand, $version = null) {
if (empty($version)) {
return true; // no version specified
}
- if (preg_match("/AppleWebKit\/([0-9]+)/i", $agent, $match)) {
+ if (preg_match("/AppleWebKit\/([0-9.]+)/i", $agent, $match)) {
if (version_compare($match[1], $version) >= 0) {
return true;
}
@@ -8420,7 +8427,7 @@ function check_browser_version($brand, $version = null) {
if (empty($version)) {
return true; // no version specified
}
- if (preg_match("/AppleWebKit\/([0-9]+)/i", $agent, $match)) {
+ if (preg_match("/AppleWebKit\/([0-9.]+)/i", $agent, $match)) {
if (version_compare($match[1], $version) >= 0) {
return true;
}
@@ -8670,7 +8677,7 @@ function get_browser_version_classes() {
function can_use_rotated_text() {
global $USER;
return (check_browser_version('MSIE', 9) || check_browser_version('Firefox', 2) ||
- check_browser_version('Chrome', 21) || check_browser_version('Safari', 536.26) ||
+ check_browser_version('Chrome', 21) || check_browser_version('Safari', 536.25) ||
check_browser_version('Opera', 12) || check_browser_version('Safari iOS', 533)) &&
!$USER->screenreader;
}

0 comments on commit 1d075ea

Please sign in to comment.