From 17f0c1e1cd4c6c63a726ab4b360a880fa5e91478 Mon Sep 17 00:00:00 2001 From: Faisal Salman Date: Tue, 24 Oct 2023 00:09:53 +0700 Subject: [PATCH] Improve browser detection: WeChat --- src/main/ua-parser.js | 13 ++++++------- test/specs/browser-all.json | 4 ++-- test/specs/os-all.json | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/main/ua-parser.js b/src/main/ua-parser.js index 5d6c8d236..1314d9d99 100755 --- a/src/main/ua-parser.js +++ b/src/main/ua-parser.js @@ -318,8 +318,7 @@ /(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i // UCBrowser ], [VERSION, [NAME, 'UCBrowser']], [ /microm.+\bqbcore\/([\w\.]+)/i, // WeChat Desktop for Windows Built-in Browser - /\bqbcore\/([\w\.]+).+microm/i - ], [VERSION, [NAME, 'WeChat(Win) Desktop']], [ + /\bqbcore\/([\w\.]+).+microm/i, /micromessenger\/([\w\.]+)/i // WeChat ], [VERSION, [NAME, 'WeChat']], [ /konqueror\/([\w\.]+)/i // Konqueror @@ -757,12 +756,12 @@ // Windows /microsoft (windows) (vista|xp)/i // Windows (iTunes) ], [NAME, VERSION], [ - /(windows) nt 6\.2; (arm)/i, // Windows RT - /(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i, // Windows Phone - /(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i + /(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i // Windows Phone ], [NAME, [VERSION, strMapper, windowsVersionMap]], [ - /(win(?=3|9|n)|win 9x )([nt\d\.]+)/i - ], [[NAME, WINDOWS], [VERSION, strMapper, windowsVersionMap]], [ + /windows nt 6\.2; (arm)/i, // Windows RT + /windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i, + /(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i + ], [[VERSION, strMapper, windowsVersionMap], [NAME, WINDOWS]], [ // iOS/macOS /ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i, // iOS diff --git a/test/specs/browser-all.json b/test/specs/browser-all.json index c4c161db6..98e5f6ca1 100644 --- a/test/specs/browser-all.json +++ b/test/specs/browser-all.json @@ -1743,7 +1743,7 @@ "ua" : "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 MicroMessenger/6.5.2.501 NetType/WIFI WindowsWechat QBCore/3.43.901.400 QQBrowser/9.0.2524.400", "expect" : { - "name" : "WeChat(Win) Desktop", + "name" : "WeChat", "version" : "3.43.901.400", "major" : "3" } @@ -1753,7 +1753,7 @@ "ua" : "mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, like gecko) chrome/53.0.2785.116 safari/537.36 qbcore/4.0.1301.400 qqbrowser/9.0.2524.400 mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, like gecko) chrome/81.0.4044.138 safari/537.36 nettype/wifi micromessenger/7.0.20.1781(0x6700143b) windowswechat", "expect" : { - "name" : "WeChat(Win) Desktop", + "name" : "WeChat", "version" : "4.0.1301.400", "major" : "4" } diff --git a/test/specs/os-all.json b/test/specs/os-all.json index 5bf7630b0..9ad108cbb 100644 --- a/test/specs/os-all.json +++ b/test/specs/os-all.json @@ -80,6 +80,24 @@ "version" : "10" } }, + { + "desc" : "WeChat Desktop for Windows Built-in Browser", + "ua" : "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 MicroMessenger/6.5.2.501 NetType/WIFI WindowsWechat QBCore/3.43.901.400 QQBrowser/9.0.2524.400", + "expect" : + { + "name" : "Windows", + "version" : "7" + } + }, + { + "desc" : "WeChat Desktop for Windows Built-in Browser major version in 4", + "ua" : "mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, like gecko) chrome/81.0.4044.138 safari/537.36 nettype/wifi micromessenger/7.0.20.1781(0x6700143b) windowswechat", + "expect" : + { + "name" : "Windows", + "version" : "7" + } + }, { "desc" : "Windows RT", "ua" : "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0)",