browser 2.7.1 → 5.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +1 -1
- data/.github/workflows/tests.yml +57 -0
- data/.gitignore +1 -0
- data/.prettierignore +1 -0
- data/.rubocop.yml +13 -1
- data/CHANGELOG.md +122 -13
- data/FUNDING.yml +3 -0
- data/README.md +134 -88
- data/Rakefile +8 -1
- data/bot_exceptions.yml +1 -0
- data/bots.yml +300 -293
- data/browser.gemspec +4 -1
- data/gemfiles/{rails5.gemfile → rails6_1.gemfile} +1 -1
- data/lib/browser/accept_language.rb +4 -4
- data/lib/browser/aliases.rb +1 -1
- data/lib/browser/alipay.rb +1 -1
- data/lib/browser/base.rb +82 -18
- data/lib/browser/blackberry.rb +1 -1
- data/lib/browser/bot/empty_user_agent_matcher.rb +11 -0
- data/lib/browser/bot/keyword_matcher.rb +11 -0
- data/lib/browser/bot/known_bots_matcher.rb +11 -0
- data/lib/browser/bot.rb +34 -26
- data/lib/browser/browser.rb +59 -56
- data/lib/browser/chrome.rb +13 -3
- data/lib/browser/device/android.rb +1 -1
- data/lib/browser/device/blackberry_playbook.rb +1 -1
- data/lib/browser/device/ipad.rb +1 -1
- data/lib/browser/device/iphone.rb +1 -1
- data/lib/browser/device/ipod_touch.rb +1 -1
- data/lib/browser/device/kindle.rb +1 -1
- data/lib/browser/device/kindle_fire.rb +1 -1
- data/lib/browser/device/playstation3.rb +1 -1
- data/lib/browser/device/playstation4.rb +1 -1
- data/lib/browser/device/psp.rb +1 -1
- data/lib/browser/device/psvita.rb +1 -1
- data/lib/browser/device/samsung.rb +33 -0
- data/lib/browser/device/surface.rb +1 -1
- data/lib/browser/device/switch.rb +1 -1
- data/lib/browser/device/tv.rb +1 -1
- data/lib/browser/device/unknown.rb +1 -1
- data/lib/browser/device/wii.rb +1 -1
- data/lib/browser/device/wiiu.rb +1 -1
- data/lib/browser/device/xbox_360.rb +1 -1
- data/lib/browser/device/xbox_one.rb +1 -1
- data/lib/browser/device.rb +37 -27
- data/lib/browser/duck_duck_go.rb +22 -0
- data/lib/browser/edge.rb +3 -3
- data/lib/browser/electron.rb +1 -1
- data/lib/browser/facebook.rb +1 -1
- data/lib/browser/firefox.rb +1 -1
- data/lib/browser/google_search_app.rb +21 -0
- data/lib/browser/huawei_browser.rb +21 -0
- data/lib/browser/instagram.rb +1 -1
- data/lib/browser/internet_explorer.rb +2 -2
- data/lib/browser/maxthon.rb +21 -0
- data/lib/browser/meta/base.rb +0 -1
- data/lib/browser/meta.rb +12 -13
- data/lib/browser/micro_messenger.rb +1 -1
- data/lib/browser/middleware/context/additions.rb +1 -1
- data/lib/browser/middleware.rb +1 -1
- data/lib/browser/miui_browser.rb +21 -0
- data/lib/browser/nokia.rb +1 -1
- data/lib/browser/opera.rb +1 -1
- data/lib/browser/otter.rb +1 -1
- data/lib/browser/phantom_js.rb +1 -1
- data/lib/browser/platform/adobe_air.rb +1 -1
- data/lib/browser/platform/android.rb +1 -1
- data/lib/browser/platform/base.rb +3 -2
- data/lib/browser/platform/blackberry.rb +1 -1
- data/lib/browser/platform/chrome_os.rb +1 -1
- data/lib/browser/platform/firefox_os.rb +1 -1
- data/lib/browser/platform/ios.rb +2 -2
- data/lib/browser/platform/kai_os.rb +23 -0
- data/lib/browser/platform/linux.rb +1 -1
- data/lib/browser/platform/mac.rb +5 -3
- data/lib/browser/platform/{other.rb → unknown.rb} +3 -3
- data/lib/browser/platform/windows.rb +2 -2
- data/lib/browser/platform/windows_mobile.rb +1 -1
- data/lib/browser/platform/windows_phone.rb +1 -1
- data/lib/browser/platform.rb +37 -28
- data/lib/browser/qq.rb +1 -1
- data/lib/browser/rails.rb +3 -3
- data/lib/browser/safari.rb +16 -1
- data/lib/browser/samsung_browser.rb +21 -0
- data/lib/browser/snapchat.rb +1 -1
- data/lib/browser/sougou_browser.rb +24 -0
- data/lib/browser/sputnik.rb +2 -5
- data/lib/browser/uc_browser.rb +1 -1
- data/lib/browser/{generic.rb → unknown.rb} +3 -3
- data/lib/browser/version.rb +1 -1
- data/lib/browser/weibo.rb +1 -1
- data/lib/browser/yandex.rb +1 -1
- data/lib/browser.rb +2 -2
- data/samsung.yml +138 -0
- data/test/browser_test.rb +37 -10
- data/test/test_helper.rb +8 -0
- data/test/ua.yml +26 -3
- data/test/ua_bots.yml +9 -2
- data/test/ua_search_engines.yml +1 -0
- data/test/unit/accept_language_test.rb +6 -0
- data/test/unit/adobe_air_test.rb +1 -1
- data/test/unit/alipay_test.rb +6 -0
- data/test/unit/blackberry_test.rb +0 -6
- data/test/unit/bots_test.rb +26 -39
- data/test/unit/chrome_test.rb +8 -3
- data/test/unit/console_test.rb +2 -2
- data/test/unit/device_test.rb +30 -3
- data/test/unit/duck_duck_go_test.rb +37 -0
- data/test/unit/edge_test.rb +34 -6
- data/test/unit/firefox_test.rb +0 -3
- data/test/unit/google_search_app_test.rb +54 -0
- data/test/unit/huawei_browser_test.rb +25 -0
- data/test/unit/internet_explorer_test.rb +0 -12
- data/test/unit/ios_test.rb +0 -5
- data/test/unit/kai_os_test.rb +31 -0
- data/test/unit/kindle_test.rb +0 -2
- data/test/unit/maxthon_test.rb +25 -0
- data/test/unit/meta_test.rb +10 -2
- data/test/unit/micro_messenger_test.rb +21 -6
- data/test/unit/miui_browser_test.rb +25 -0
- data/test/unit/opera_test.rb +1 -2
- data/test/unit/platform_test.rb +13 -8
- data/test/unit/qq_test.rb +12 -0
- data/test/unit/safari_test.rb +12 -7
- data/test/unit/samsung_browser_test.rb +23 -0
- data/test/unit/sougou_browser_test.rb +41 -0
- data/test/unit/sputnik_test.rb +1 -0
- metadata +46 -16
- data/.bundle/config +0 -2
- data/.travis.yml +0 -23
- data/lib/browser/meta/modern.rb +0 -11
- /data/gemfiles/{rails6.gemfile → rails6_0.gemfile} +0 -0
data/lib/browser/device/tv.rb
CHANGED
data/lib/browser/device/wii.rb
CHANGED
data/lib/browser/device/wiiu.rb
CHANGED
data/lib/browser/device.rb
CHANGED
@@ -1,25 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
3
|
+
require_relative "device/base"
|
4
|
+
require_relative "device/android"
|
5
|
+
require_relative "device/unknown"
|
6
|
+
require_relative "device/ipad"
|
7
|
+
require_relative "device/ipod_touch"
|
8
|
+
require_relative "device/iphone"
|
9
|
+
require_relative "device/playstation3"
|
10
|
+
require_relative "device/playstation4"
|
11
|
+
require_relative "device/psp"
|
12
|
+
require_relative "device/psvita"
|
13
|
+
require_relative "device/kindle"
|
14
|
+
require_relative "device/kindle_fire"
|
15
|
+
require_relative "device/wii"
|
16
|
+
require_relative "device/wiiu"
|
17
|
+
require_relative "device/blackberry_playbook"
|
18
|
+
require_relative "device/surface"
|
19
|
+
require_relative "device/switch"
|
20
|
+
require_relative "device/tv"
|
21
|
+
require_relative "device/xbox_one"
|
22
|
+
require_relative "device/xbox_360"
|
23
|
+
require_relative "device/samsung"
|
23
24
|
|
24
25
|
module Browser
|
25
26
|
class Device
|
@@ -29,6 +30,7 @@ module Browser
|
|
29
30
|
# Order is important.
|
30
31
|
def self.matchers
|
31
32
|
@matchers ||= [
|
33
|
+
Samsung,
|
32
34
|
XboxOne,
|
33
35
|
Xbox360,
|
34
36
|
Surface,
|
@@ -88,7 +90,7 @@ module Browser
|
|
88
90
|
end
|
89
91
|
|
90
92
|
def unknown?
|
91
|
-
id == :
|
93
|
+
id == :unknown_device
|
92
94
|
end
|
93
95
|
|
94
96
|
def ipod_touch?
|
@@ -158,12 +160,12 @@ module Browser
|
|
158
160
|
|
159
161
|
# Detect if browser is Silk.
|
160
162
|
def silk?
|
161
|
-
ua
|
163
|
+
ua.include?("Silk")
|
162
164
|
end
|
163
165
|
|
164
166
|
# Detect if browser is running under Xbox.
|
165
167
|
def xbox?
|
166
|
-
ua
|
168
|
+
ua.include?("Xbox")
|
167
169
|
end
|
168
170
|
|
169
171
|
# Detect if browser is running under Xbox 360.
|
@@ -191,18 +193,26 @@ module Browser
|
|
191
193
|
xbox? || playstation? || nintendo?
|
192
194
|
end
|
193
195
|
|
196
|
+
# Detect if device is a Samsung.
|
197
|
+
def samsung?
|
198
|
+
id == :samsung
|
199
|
+
end
|
200
|
+
|
194
201
|
# Regex taken from http://detectmobilebrowsers.com
|
195
|
-
# rubocop:disable
|
202
|
+
# rubocop:disable Layout/LineLength
|
196
203
|
private def detect_mobile?
|
197
204
|
psp? ||
|
198
|
-
/zunewp7/i.match(ua) ||
|
205
|
+
/zunewp7/i.match?(ua) ||
|
199
206
|
%r{(android|bb\d+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino}i.match(ua) ||
|
200
|
-
%r{1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s
|
207
|
+
%r{1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-}i.match?(ua[0..3])
|
201
208
|
end
|
202
|
-
# rubocop:enable
|
209
|
+
# rubocop:enable Layout/LineLength
|
203
210
|
|
204
211
|
private def platform
|
205
212
|
@platform ||= Platform.new(ua)
|
206
213
|
end
|
214
|
+
|
215
|
+
private :subject
|
216
|
+
private :ua
|
207
217
|
end
|
208
218
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Browser
|
4
|
+
class DuckDuckGo < Base
|
5
|
+
def id
|
6
|
+
:duckduckgo
|
7
|
+
end
|
8
|
+
|
9
|
+
def name
|
10
|
+
"DuckDuckGo"
|
11
|
+
end
|
12
|
+
|
13
|
+
def full_version
|
14
|
+
ua[%r{DuckDuckGo/([\d.]+)}, 1] ||
|
15
|
+
"0.0"
|
16
|
+
end
|
17
|
+
|
18
|
+
def match?
|
19
|
+
ua.include?("DuckDuckGo")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/browser/edge.rb
CHANGED
@@ -11,15 +11,15 @@ module Browser
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def full_version
|
14
|
-
ua[%r{(?:Edge|Edg)/([\d.]+)}, 1] || super
|
14
|
+
ua[%r{(?:Edge|Edg|EdgiOS|EdgA)/([\d.]+)}, 1] || super
|
15
15
|
end
|
16
16
|
|
17
17
|
def match?
|
18
|
-
ua
|
18
|
+
ua.match?(%r{((?:Edge|Edg|EdgiOS|EdgA)/[\d.]+|Trident/8)})
|
19
19
|
end
|
20
20
|
|
21
21
|
def chrome_based?
|
22
|
-
match? && ua
|
22
|
+
match? && ua.match?(/\bEdg\b/)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
data/lib/browser/electron.rb
CHANGED
data/lib/browser/facebook.rb
CHANGED
data/lib/browser/firefox.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Browser
|
4
|
+
class GoogleSearchApp < Chrome
|
5
|
+
def id
|
6
|
+
:google_search_app
|
7
|
+
end
|
8
|
+
|
9
|
+
def name
|
10
|
+
"Google Search App"
|
11
|
+
end
|
12
|
+
|
13
|
+
def full_version
|
14
|
+
ua[%r{GSA/([\d.]+\d)}, 1] || super
|
15
|
+
end
|
16
|
+
|
17
|
+
def match?
|
18
|
+
ua.include?("GSA")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Browser
|
4
|
+
class HuaweiBrowser < Base
|
5
|
+
def id
|
6
|
+
:huawei_browser
|
7
|
+
end
|
8
|
+
|
9
|
+
def name
|
10
|
+
"Huawei Browser"
|
11
|
+
end
|
12
|
+
|
13
|
+
def full_version
|
14
|
+
ua[%r{(?:HuaweiBrowser)/([\d.]+)}i, 1] || "0.0"
|
15
|
+
end
|
16
|
+
|
17
|
+
def match?
|
18
|
+
ua.match?(/HuaweiBrowser/i)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/browser/instagram.rb
CHANGED
@@ -52,11 +52,11 @@ module Browser
|
|
52
52
|
end
|
53
53
|
|
54
54
|
private def msie?
|
55
|
-
ua
|
55
|
+
ua.include?("MSIE") && !ua.include?("Opera")
|
56
56
|
end
|
57
57
|
|
58
58
|
private def modern_ie?
|
59
|
-
ua
|
59
|
+
ua.match?(%r{Trident/.*?; rv:(.*?)})
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Browser
|
4
|
+
class Maxthon < Base
|
5
|
+
def id
|
6
|
+
:maxthon
|
7
|
+
end
|
8
|
+
|
9
|
+
def name
|
10
|
+
"Maxthon"
|
11
|
+
end
|
12
|
+
|
13
|
+
def full_version
|
14
|
+
ua[%r{(?:Maxthon)/([\d.]+)}i, 1] || "0.0"
|
15
|
+
end
|
16
|
+
|
17
|
+
def match?
|
18
|
+
ua.match?(/Maxthon/i)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/browser/meta/base.rb
CHANGED
data/lib/browser/meta.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
require "browser/meta/device"
|
3
|
+
require_relative "meta/base"
|
4
|
+
require_relative "meta/generic_browser"
|
5
|
+
require_relative "meta/id"
|
6
|
+
require_relative "meta/ie"
|
7
|
+
require_relative "meta/ios"
|
8
|
+
require_relative "meta/mobile"
|
9
|
+
require_relative "meta/platform"
|
10
|
+
require_relative "meta/proxy"
|
11
|
+
require_relative "meta/safari"
|
12
|
+
require_relative "meta/webkit"
|
13
|
+
require_relative "meta/tablet"
|
14
|
+
require_relative "meta/device"
|
data/lib/browser/middleware.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Browser
|
4
|
+
class MiuiBrowser < Base
|
5
|
+
def id
|
6
|
+
:miui_browser
|
7
|
+
end
|
8
|
+
|
9
|
+
def name
|
10
|
+
"Miui Browser"
|
11
|
+
end
|
12
|
+
|
13
|
+
def full_version
|
14
|
+
ua[%r{MiuiBrowser/([\d.]+)}, 1] || "0.0"
|
15
|
+
end
|
16
|
+
|
17
|
+
def match?
|
18
|
+
ua.include?("MiuiBrowser")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/browser/nokia.rb
CHANGED
data/lib/browser/opera.rb
CHANGED
data/lib/browser/otter.rb
CHANGED
data/lib/browser/phantom_js.rb
CHANGED
data/lib/browser/platform/ios.rb
CHANGED
@@ -5,7 +5,7 @@ module Browser
|
|
5
5
|
class IOS < Base
|
6
6
|
MATCHER = /(iPhone|iPad|iPod)/.freeze
|
7
7
|
VERSION_MATCHER =
|
8
|
-
/OS (
|
8
|
+
/OS (?<major>\d+)_(?<minor>\d+)_?(?<patch>\d+)?/.freeze
|
9
9
|
|
10
10
|
def version
|
11
11
|
matches = VERSION_MATCHER.match(ua)
|
@@ -32,7 +32,7 @@ module Browser
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def match?
|
35
|
-
ua
|
35
|
+
ua.match?(MATCHER)
|
36
36
|
end
|
37
37
|
|
38
38
|
def device
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Browser
|
4
|
+
class Platform
|
5
|
+
class KaiOS < Base
|
6
|
+
def version
|
7
|
+
ua[%r{KAIOS/([\d.]+)}, 1]
|
8
|
+
end
|
9
|
+
|
10
|
+
def name
|
11
|
+
"KaiOS"
|
12
|
+
end
|
13
|
+
|
14
|
+
def id
|
15
|
+
:kai_os
|
16
|
+
end
|
17
|
+
|
18
|
+
def match?
|
19
|
+
ua.include?("KAIOS")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/browser/platform/mac.rb
CHANGED
@@ -4,11 +4,13 @@ module Browser
|
|
4
4
|
class Platform
|
5
5
|
class Mac < Base
|
6
6
|
def version
|
7
|
-
(ua[/Mac OS X\s*([0-9_
|
7
|
+
(ua[/Mac OS X\s*([0-9_.]+)?/, 1] || "0").tr("_", ".")
|
8
8
|
end
|
9
9
|
|
10
10
|
def name
|
11
|
-
"
|
11
|
+
return "macOS" if platform.mac?(">= 10.12")
|
12
|
+
|
13
|
+
"Mac OS X"
|
12
14
|
end
|
13
15
|
|
14
16
|
def id
|
@@ -16,7 +18,7 @@ module Browser
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def match?
|
19
|
-
ua
|
21
|
+
ua.include?("Mac")
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|