Bug 1610003 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

A site is using the following function for UA detection:

```
detect: function() {
        embeddedPlayer.debugOutput("EmbeddedPlayer: platform detection");
        var e,
          t,
          a,
          d = window.navigator.userAgent,
          n = window.navigator.platform;
        /MSIE/.test(d)
          ? ((e = "Internet Explorer"),
            /IEMobile/.test(d) && (e += " Mobile"),
            (a = /MSIE \d+[.]\d+/.exec(d)[0].split(" ")[1]))
          : /Trident/.test(d)
          ? ((e = "Internet Explorer"),
            /IEMobile/.test(d) && (e += " Mobile"),
            (a = /rv:\d+[.]\d+/.exec(d)[0].split(":")[1]))
          : /Chrome/.test(d)
          ? ((e = "Chrome"), (a = /Chrome\/[\d\.]+/.exec(d)[0].split("/")[1]))
          : /Opera/.test(d)
          ? ((e = "Opera"),
            /mini/.test(d)
              ? (e += " Mini")
              : /Mobile/.test(d) && (e += " Mobile"))
          : /Android/.test(d)
          ? ((e = "Android Webkit Browser"),
            (mobile = !0),
            (t = /Android\s[\.\d]+/.exec(d)))
          : /Firefox/.test(d)
          ? ((e = "Firefox"),
            /Fennec/.test(d) && (e += " Mobile"),
            (a = /Firefox\/[\.\d]+/.exec(d)[0].split("/")[1]))
          : /Safari/.test(d)
          ? ((e = "Safari"),
            /CriOS/.test(d)
              ? ((t = "iOS"),
                (e = "Chrome"),
                (a = /CriOS\/[\.\d]+/.exec(d)[0].split("/")[1]))
              : (/iPhone/.test(d) || /iPad/.test(d) || /iPod/.test(d)) &&
                (t = "iOS"))
          : (/iPhone/.test(d) ||
              /iPad/.test(d) ||
              /iOS/.test(d) ||
              /CFNetwork.*Darwin/.test(d)) &&
            ((e = "Safari"),
            (t = "iOS"),
            (a = /Darwin/.test(d)
              ? /Darwin\/[\.\d]+/.exec(d)[0].split("/")[1]
              : /FBAV/.test(d)
              ? /FBAV\/[\.\d]+/.exec(d)[0].split("/")[1]
              : "1.0")),
          a ||
            (a = (a = /Version\/[\.\d]+/.exec(d))
              ? a[0].split("/")[1]
              : /Opera\/[\.\d]+/.exec(d)[0].split("/")[1]),
          void 0 !== t || ("MacIntel" !== n && "MacPPC" !== n)
            ? "Win32" === n
              ? (t = "Windows 32 bit")
              : "Win64" == n
              ? (t = "Windows 64 bit")
              : !t && /Linux/.test(n)
              ? (t = "Linux")
              : !t && /Windows/.test(d) && (t = "Windows")
            : /10[\.\_\d]+/.exec(d) &&
              ((t = "Mac OS X " + /10[\.\_\d]+/.exec(d)[0]),
              /[\_]/.test(t) && (t = t.split("_").join("."))),
          void 0 === t && (t = "");
        var r = window.MediaSource || window.WebKitMediaSource;
        window.ui = {
            browser: e,
            version: a,
            os: t,
            userAgent: d,
            mse: !!r
        }
    }
```
It results in an error at this point:
```
          a ||
            (a = (a = /Version\/[\.\d]+/.exec(d))
              ? a[0].split("/")[1]
              : /Opera\/[\.\d]+/.exec(d)[0].split("/")[1]),
```
For an override we'd need to come up with an UA string that would not result in this function erroring out
A site is using the following function for UA detection:

```
detect: function() {
        embeddedPlayer.debugOutput("EmbeddedPlayer: platform detection");
        var e,
          t,
          a,
          d = window.navigator.userAgent,
          n = window.navigator.platform;
        /MSIE/.test(d)
          ? ((e = "Internet Explorer"),
            /IEMobile/.test(d) && (e += " Mobile"),
            (a = /MSIE \d+[.]\d+/.exec(d)[0].split(" ")[1]))
          : /Trident/.test(d)
          ? ((e = "Internet Explorer"),
            /IEMobile/.test(d) && (e += " Mobile"),
            (a = /rv:\d+[.]\d+/.exec(d)[0].split(":")[1]))
          : /Chrome/.test(d)
          ? ((e = "Chrome"), (a = /Chrome\/[\d\.]+/.exec(d)[0].split("/")[1]))
          : /Opera/.test(d)
          ? ((e = "Opera"),
            /mini/.test(d)
              ? (e += " Mini")
              : /Mobile/.test(d) && (e += " Mobile"))
          : /Android/.test(d)
          ? ((e = "Android Webkit Browser"),
            (mobile = !0),
            (t = /Android\s[\.\d]+/.exec(d)))
          : /Firefox/.test(d)
          ? ((e = "Firefox"),
            /Fennec/.test(d) && (e += " Mobile"),
            (a = /Firefox\/[\.\d]+/.exec(d)[0].split("/")[1]))
          : /Safari/.test(d)
          ? ((e = "Safari"),
            /CriOS/.test(d)
              ? ((t = "iOS"),
                (e = "Chrome"),
                (a = /CriOS\/[\.\d]+/.exec(d)[0].split("/")[1]))
              : (/iPhone/.test(d) || /iPad/.test(d) || /iPod/.test(d)) &&
                (t = "iOS"))
          : (/iPhone/.test(d) ||
              /iPad/.test(d) ||
              /iOS/.test(d) ||
              /CFNetwork.*Darwin/.test(d)) &&
            ((e = "Safari"),
            (t = "iOS"),
            (a = /Darwin/.test(d)
              ? /Darwin\/[\.\d]+/.exec(d)[0].split("/")[1]
              : /FBAV/.test(d)
              ? /FBAV\/[\.\d]+/.exec(d)[0].split("/")[1]
              : "1.0")),
          a ||
            (a = (a = /Version\/[\.\d]+/.exec(d))
              ? a[0].split("/")[1]
              : /Opera\/[\.\d]+/.exec(d)[0].split("/")[1]),
          void 0 !== t || ("MacIntel" !== n && "MacPPC" !== n)
            ? "Win32" === n
              ? (t = "Windows 32 bit")
              : "Win64" == n
              ? (t = "Windows 64 bit")
              : !t && /Linux/.test(n)
              ? (t = "Linux")
              : !t && /Windows/.test(d) && (t = "Windows")
            : /10[\.\_\d]+/.exec(d) &&
              ((t = "Mac OS X " + /10[\.\_\d]+/.exec(d)[0]),
              /[\_]/.test(t) && (t = t.split("_").join("."))),
          void 0 === t && (t = "");
        var r = window.MediaSource || window.WebKitMediaSource;
        window.ui = {
            browser: e,
            version: a,
            os: t,
            userAgent: d,
            mse: !!r
        }
    }
```
It results in an error at this point:
```
          a ||
            (a = (a = /Version\/[\.\d]+/.exec(d))
              ? a[0].split("/")[1]
              : /Opera\/[\.\d]+/.exec(d)[0].split("/")[1]),
```
For an override we'd need to come up with an UA string that would not result in this function erroring out. This should only happen for mobile

Back to Bug 1610003 Comment 0