From 6a80dd0b2dad8a0f38cdd008bc55a72172ebbd92 Mon Sep 17 00:00:00 2001 From: Lu Date: Thu, 6 Aug 2015 21:19:20 +0200 Subject: [PATCH 1/3] Fixed the WP8.1 / IE11 bug on the JavaScript library. IE11 has in the user agent both android and iphone and that caused it to be detected in a wrong way. Here the details: http://www.neowin.net/news/ie11-fakes-user-agent-to-fool-gmail-in-windows-phone-81-gdr1-update --- JavaScript/mdetect.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/JavaScript/mdetect.js b/JavaScript/mdetect.js index d7a3a13..d87a890 100755 --- a/JavaScript/mdetect.js +++ b/JavaScript/mdetect.js @@ -1,4 +1,4 @@ -/* ******************************************* +/* ******************************************* // Copyright 2010-2015, Anthony Hand // // BETA NOTICE @@ -254,10 +254,11 @@ var MobileEsp = { //************************** // Detects if the current device is an iPhone. DetectIphone : function() { + if (this.initCompleted || this.isIphone) return this.isIphone; - if (this.uagent.search(this.deviceIphone) > -1) + if (!this.DetectWindowsPhone() && (this.uagent.search(this.deviceIphone) > -1)) { //The iPad and iPod Touch say they're an iPhone! So let's disambiguate. if (this.DetectIpad() || this.DetectIpod()) @@ -315,10 +316,11 @@ var MobileEsp = { // Detects *any* Android OS-based device: phone, tablet, and multi-media player. // Also detects Google TV. DetectAndroid : function() { + if (this.initCompleted || this.isAndroid) return this.isAndroid; - if ((this.uagent.search(this.deviceAndroid) > -1) || this.DetectGoogleTV()) + if (!this.DetectWindowsPhone() && ((this.uagent.search(this.deviceAndroid) > -1) || this.DetectGoogleTV())) return true; return false; @@ -1154,7 +1156,4 @@ var MobileEsp = { }; //Initialize the MobileEsp object -MobileEsp.InitDeviceScan(); - - - +MobileEsp.InitDeviceScan(); \ No newline at end of file From e7eb5099c77b10edaef353dcc915cccdaa518426 Mon Sep 17 00:00:00 2001 From: Lu Date: Thu, 6 Aug 2015 21:33:49 +0200 Subject: [PATCH 2/3] Fixed the WP8.1 / IE11 bug on the Java library. --- Java/UAgentInfo.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Java/UAgentInfo.java b/Java/UAgentInfo.java index 5703f6d..627507a 100755 --- a/Java/UAgentInfo.java +++ b/Java/UAgentInfo.java @@ -307,7 +307,8 @@ public void initDeviceScan() { */ public boolean detectIphone() { // The iPad and iPod touch say they're an iPhone! So let's disambiguate. - if (userAgent.indexOf(deviceIphone) != -1 && + if (userAgent.indexOf(deviceWinPhone8) == -1 && + userAgent.indexOf(deviceIphone) != -1 && !detectIpad() && !detectIpod()) { return true; @@ -369,8 +370,9 @@ public boolean detectIos() { * @return detection of an Android device */ public boolean detectAndroid() { - if ((userAgent.indexOf(deviceAndroid) != -1) || - detectGoogleTV()) + if (userAgent.indexOf(deviceWinPhone8) == -1 && + ((userAgent.indexOf(deviceAndroid) != -1) || + detectGoogleTV())) return true; return false; From 47b85b8a0db9eded0e295fbbaf482ff2956670f5 Mon Sep 17 00:00:00 2001 From: Lu Date: Mon, 10 Aug 2015 11:02:24 +0200 Subject: [PATCH 3/3] Fixed the WP8.1 / IE11 bug on the Python and PHP libraries. --- Java/UAgentInfo.java | 4 ++-- PHP/mdetect.php | 6 ++++-- Python/mdetect.py | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Java/UAgentInfo.java b/Java/UAgentInfo.java index 627507a..f602261 100755 --- a/Java/UAgentInfo.java +++ b/Java/UAgentInfo.java @@ -307,7 +307,7 @@ public void initDeviceScan() { */ public boolean detectIphone() { // The iPad and iPod touch say they're an iPhone! So let's disambiguate. - if (userAgent.indexOf(deviceWinPhone8) == -1 && + if (!detectWindowsPhone10() && userAgent.indexOf(deviceIphone) != -1 && !detectIpad() && !detectIpod()) { @@ -370,7 +370,7 @@ public boolean detectIos() { * @return detection of an Android device */ public boolean detectAndroid() { - if (userAgent.indexOf(deviceWinPhone8) == -1 && + if (!detectWindowsPhone10() && ((userAgent.indexOf(deviceAndroid) != -1) || detectGoogleTV())) return true; diff --git a/PHP/mdetect.php b/PHP/mdetect.php index 47810a4..6d003bf 100755 --- a/PHP/mdetect.php +++ b/PHP/mdetect.php @@ -279,7 +279,8 @@ function Get_HttpAccept() // Detects if the current device is an iPhone. function DetectIphone() { - if ($this->initCompleted == $this->true || + if (!($this->DetectWindowsPhone()) && + $this->initCompleted == $this->true || $this->isIphone == $this->true) return $this->isIphone; @@ -347,7 +348,8 @@ function DetectIos() // Also detects Google TV. function DetectAndroid() { - if ($this->initCompleted == $this->true || + if (!($this->DetectWindowsPhone()) && + $this->initCompleted == $this->true || $this->isAndroid == $this->true) return $this->isAndroid; diff --git a/Python/mdetect.py b/Python/mdetect.py index fe8592e..8a7e1a9 100755 --- a/Python/mdetect.py +++ b/Python/mdetect.py @@ -272,7 +272,8 @@ def detectIphone(self): Detects if the current device is an iPhone. """ # The iPad and iPod touch say they're an iPhone! So let's disambiguate. - return UAgentInfo.deviceIphone in self.__userAgent \ + return not self.detectWindowsPhone() \ + and UAgentInfo.deviceIphone in self.__userAgent \ and not self.detectIpad() \ and not self.detectIpod() @@ -315,7 +316,8 @@ def detectAndroid(self): Detects *any* Android OS-based device: phone, tablet, and multi-media player. Also detects Google TV. """ - if UAgentInfo.deviceAndroid in self.__userAgent \ + if not self.detectWindowsPhone() \ + and UAgentInfo.deviceAndroid in self.__userAgent \ or self.detectGoogleTV(): return True