Moodle
  1. Moodle
  2. MDL-36481

IE8/9/10 user agent detection on intranet sites may be incorrect

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.4
    • Fix Version/s: 2.4
    • Component/s: Libraries
    • Labels:
    • Testing Instructions:
      Hide

      1/ run unit tests
      2/ test svg icons and body examine the body class matches the selected browser compatibility in IE9+IE10
      3/ add your test site to the list of intranet sites in IE (Internet options / Security / Local intranet / ...)
      4/ repeat step2, the body class should be the same as before

      Show
      1/ run unit tests 2/ test svg icons and body examine the body class matches the selected browser compatibility in IE9+IE10 3/ add your test site to the list of intranet sites in IE (Internet options / Security / Local intranet / ...) 4/ repeat step2, the body class should be the same as before
    • Affected Branches:
      MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      w46_MDL-36481_m24_intranetie
    • Rank:
      45937

      Description

      When using a local (intranet) site, IE8+ will visit it in IE7 compatibility mode. Moodle now uses a meta tag in the theme to force IE to use its latest rendering mode, which solves this problem. However, the user agent remains as the IE7 user agent.

      Parts of Moodle code that detect IE version should be modified so that they correctly detect the 'IE9 pretending to be IE7' user agent. This applies at least to the get_browser_classes function, maybe also the check_browser_version or whatever that is called?

      You can detect these user agents because (a) they look like IE7, (b) they have Trident/something.

      Here is example code used at OU to modify the output of get_browser_classes:

          if ($useragent) {
              // Speculatively support IE11, IE12 even though they don't exist yet.
              if (strpos($useragent, 'Trident/4.0') !== false) {
                  $classes = str_replace('ie7', 'ie8', $classes);
              } else if (strpos($useragent, 'Trident/5.0') !== false) {
                  $classes = str_replace('ie7', 'ie9', $classes);
              } else if (strpos($useragent, 'Trident/6.0') !== false) {
                  $classes = str_replace('ie7', 'ie10', $classes);
              } else if (strpos($useragent, 'Trident/7.0') !== false) {
                  $classes = str_replace('ie7', 'ie11', $classes);
              } else if (strpos($useragent, 'Trident/8.0') !== false) {
                  $classes = str_replace('ie7', 'ie12', $classes);
              }
          }
      

        Activity

        Hide
        Petr Škoda added a comment -

        Thanks a lot for the report, I have implemented the hacks in a bit different way and fixed svg icons to work on intranet sites too.

        Show
        Petr Škoda added a comment - Thanks a lot for the report, I have implemented the hacks in a bit different way and fixed svg icons to work on intranet sites too.
        Hide
        Sam Marshall added a comment -

        That was quick! By the way, I had a quick look at it and I like the way you did the changes, +1 from me.

        Show
        Sam Marshall added a comment - That was quick! By the way, I had a quick look at it and I like the way you did the changes, +1 from me.
        Hide
        Petr Škoda added a comment -

        hehe, I spent most of the time testing that thing, thanks for the quick review!

        Show
        Petr Škoda added a comment - hehe, I spent most of the time testing that thing, thanks for the quick review!
        Hide
        Dan Poltawski added a comment -

        Integrated, thanks.

        (bah IE team, why must you make our job so hard! Please add a 'yes I really want you to be standards compliant and reporting properly option')

        Show
        Dan Poltawski added a comment - Integrated, thanks. (bah IE team, why must you make our job so hard! Please add a 'yes I really want you to be standards compliant and reporting properly option')
        Hide
        Michael de Raadt added a comment -

        Test result: Success

        Show
        Michael de Raadt added a comment - Test result: Success
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Many, many thanks for your effort!

        Millions of people will enjoy the results of your work, yay!

        Closing as fixed. Ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Many, many thanks for your effort! Millions of people will enjoy the results of your work, yay! Closing as fixed. Ciao

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: