browser_sniffer 1.2.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7466e6d392be9a8f030ff7301bfae8aa97ff0f44ebe0e31a7f662b8ddd1c45a5
4
- data.tar.gz: 22a24aa5b13e3c663416a4cb015e03c3af315193cdd398945541e18829174df1
3
+ metadata.gz: beb896967f13a26304b23513f7e2a6e334854afc3187795a7d98698a4b8a2299
4
+ data.tar.gz: b3be5e1a5068b56d87685129404b8ed369644af58adbd815c6634a8500a23221
5
5
  SHA512:
6
- metadata.gz: 0f5a4612854ada3f81857d40d536817cb1064aec4dc6f24251d25658923dd91d45230091019defe14c594422004bd053402792a4b312d8fca5a5056b80a71479
7
- data.tar.gz: 25b99d22d52f3e8dae0a9aeb345408121dd23076f4a3736dbd147ab398dd5b3490b7b09de7fb8e413664e4170d551c3683e4dc667e7e02d240cb2fd601501730
6
+ metadata.gz: b0f851fc4026c1f35e905daf515f68cd4755261fe6c1424825170dcaefa207605bdd825b821f865cecad5bcc4d99394b783f6078c29eb37a41d96ee41ccaff07
7
+ data.tar.gz: bad8fe19eb686b1d4e698805a87790cf4e48f4b0654504c5f6d761d2b7cbc97a82746eacade1cbacd210b2459b3e3065f212315b5045bd4bcbe40be09418535f
@@ -17,6 +17,8 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.required_ruby_version = ">= 1.9.3"
19
19
 
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
+
20
22
  spec.add_development_dependency "bundler"
21
23
  spec.add_development_dependency "minitest"
22
24
  spec.add_development_dependency "rake"
@@ -59,6 +59,9 @@ class BrowserSniffer
59
59
  ], [:name, :version], [
60
60
  # Shopify POS for Android (Native App)
61
61
  %r{.*(\sPOS\s-).*\s([\d+\.]+)(\/\d*)*\s}i,
62
+ ], [[:name, 'Shopify POS'], :version], [
63
+ # Shopify POS for Android (Native App) New Format
64
+ %r{(Shopify POS)\/([\d\.]+)[^\/]*\/(Android)\/(\d+)}i,
62
65
  ], [[:name, 'Shopify POS'], :version], [
63
66
  # Shopify POS for Android (SmartWebView)
64
67
  %r{.*(Shopify\sPOS)\s.*Android.*\s([\d+\.]+)(\/\d*)*\s}i,
@@ -73,8 +76,8 @@ class BrowserSniffer
73
76
  %r{.*(Shopify POS Next|Shopify POS)\/(?:iOS)\/([\d\.]+) \((iPhone|iPad|iPod)}i
74
77
  ], [[:name, 'Shopify POS'], :version], [
75
78
  # Shopify Mobile for Android
76
- %r{.*(Shopify Mobile)\/Android\/([\d\.]+(?: \(debug(?:|-push)\))?) \(Build (\d+) with API (\d+)}i
77
- ], [[:name, 'Shopify Mobile'], :version, :build, :sdk_version], [
79
+ %r{.*(Shopify Mobile)\/Android\/([\d\.]+)(?: \((debug(?:|-push))\))? \(Build (\d+) with API (\d+)}i
80
+ ], [[:name, 'Shopify Mobile'], :version, :debug_mode, :build, :sdk_version], [
78
81
  # ShopifyFoundation shared library
79
82
  /^(ShopifyFoundation)/i,
80
83
  ], [:name], [
@@ -332,7 +335,7 @@ class BrowserSniffer
332
335
  /(gnu)\s?([\w\.]+)*/i # GNU
333
336
  ], [:name, :version, [:type, :linux]], [
334
337
  /(cros)\s[\w]+\s([\w\.]+\w)/i # Chromium OS
335
- ], [[:name, 'Chromium OS'], :version],[
338
+ ], [[:name, 'Chromium OS'], :version, [:type, :chromium_os]],[
336
339
  # Solaris
337
340
  /(sunos)\s?([\w\.]+\d)*/i # Solaris
338
341
  ], [[:name, 'Solaris'], :version], [
@@ -1,3 +1,3 @@
1
1
  class BrowserSniffer
2
- VERSION = "1.2.0"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -24,6 +24,15 @@ class BrowserSniffer
24
24
  browser == :ie && major_browser_version == 11
25
25
  end
26
26
 
27
+ # This method checks ie 11 mobile or ie11 rendering an older version in compatibility mode, in addition to `ie11?`.
28
+ # The `ie11?` method would return false in both those scenarios.
29
+ def ie11_actual?
30
+ ie11_engine = major_engine_version == 7 && engine_name == 'Trident'
31
+ ie_mobile11 = major_browser_version == 11 && browser_name == 'IEMobile'
32
+
33
+ ie11? || ie11_engine || ie_mobile11
34
+ end
35
+
27
36
  def handheld?
28
37
  form_factor == :handheld
29
38
  end
@@ -454,6 +454,7 @@ class BrowserSnifferTest < Minitest::Test
454
454
  :android? => false,
455
455
  :desktop? => true,
456
456
  :ie11? => false,
457
+ :ie11_actual? => false,
457
458
  :engine => nil,
458
459
  :major_engine_version => nil,
459
460
  :os => :mac,
@@ -467,6 +468,7 @@ class BrowserSnifferTest < Minitest::Test
467
468
  :form_factor => :desktop,
468
469
  :ios? => false,
469
470
  :ie11? => true,
471
+ :ie11_actual? => true,
470
472
  :android? => false,
471
473
  :desktop? => true,
472
474
  :engine => :trident,
@@ -481,6 +483,7 @@ class BrowserSnifferTest < Minitest::Test
481
483
  :form_factor => :desktop,
482
484
  :ios? => false,
483
485
  :ie11? => true,
486
+ :ie11_actual? => true,
484
487
  :android? => false,
485
488
  :desktop? => true,
486
489
  :engine => :trident,
@@ -495,6 +498,7 @@ class BrowserSnifferTest < Minitest::Test
495
498
  :form_factor => :desktop,
496
499
  :ios? => false,
497
500
  :ie11? => true,
501
+ :ie11_actual? => true,
498
502
  :android? => false,
499
503
  :desktop? => true,
500
504
  :engine => :trident,
@@ -509,6 +513,7 @@ class BrowserSnifferTest < Minitest::Test
509
513
  :form_factor => :desktop,
510
514
  :ios? => false,
511
515
  :ie11? => true,
516
+ :ie11_actual? => true,
512
517
  :android? => false,
513
518
  :desktop? => true,
514
519
  :engine => :trident,
@@ -523,6 +528,7 @@ class BrowserSnifferTest < Minitest::Test
523
528
  :form_factor => :desktop,
524
529
  :ios? => false,
525
530
  :ie11? => false,
531
+ :ie11_actual? => false,
526
532
  :android? => false,
527
533
  :desktop? => true,
528
534
  :engine => :webkit,
@@ -544,7 +550,52 @@ class BrowserSnifferTest < Minitest::Test
544
550
  :os_version => nil,
545
551
  :browser => nil,
546
552
  :major_browser_version => nil
547
- }
553
+ },
554
+ :chromiumos_chrome => {
555
+ :user_agent => "Mozilla/5.0 (X11; CrOS x86_64 10066.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36",
556
+ :form_factor => :desktop,
557
+ :ios? => false,
558
+ :android? => false,
559
+ :desktop? => true,
560
+ :engine => :webkit,
561
+ :major_engine_version => 537,
562
+ :os => :chromium_os,
563
+ :os_version => '10066.0.0',
564
+ :browser => :chrome,
565
+ :major_browser_version => 81,
566
+ },
567
+ :windows_phone_8_1_ie11 => {
568
+ :user_agent => "Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; Microsoft; " \
569
+ "Lumia 640 XL) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537",
570
+ :form_factor => :handheld,
571
+ :ios? => false,
572
+ :ie11? => false,
573
+ :ie11_actual? => true,
574
+ :android? => false,
575
+ :desktop? => false,
576
+ :engine => :webkit,
577
+ :major_engine_version => 53,
578
+ :os => :windows,
579
+ :os_version => "8.1",
580
+ :browser => nil,
581
+ :major_browser_version => 11
582
+ },
583
+ :win10_ie11_in_ie7_compatibility_mode => {
584
+ :user_agent => "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; " \
585
+ ".NET CLR 3.0.30729; .NET CLR 3.5.30729; InfoPath.3; Tablet PC 2.0; Zoom 3.6.0)",
586
+ :form_factor => :desktop,
587
+ :ios? => false,
588
+ :ie11? => false,
589
+ :ie11_actual? => true,
590
+ :android? => false,
591
+ :desktop? => true,
592
+ :engine => :trident,
593
+ :major_engine_version => 7,
594
+ :os => :windows,
595
+ :os_version => "10",
596
+ :browser => :ie,
597
+ :major_browser_version => 7
598
+ },
548
599
  }
549
600
 
550
601
  AGENTS.each do |agent, attributes|
@@ -155,6 +155,7 @@ describe "Shopify agents" do
155
155
  assert_equal ({
156
156
  name: 'Shopify Mobile',
157
157
  version: '5.4.4',
158
+ debug_mode: nil,
158
159
  build: '12005',
159
160
  sdk_version: '25',
160
161
  }), sniffer.browser_info
@@ -174,10 +175,11 @@ describe "Shopify agents" do
174
175
  "MobileMiddlewareSupported Mozilla/5.0 (Linux; Android 9; Android SDK built for x86 Build/PSR1.180720.075; wv) "\
175
176
  "AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/69.0.3497.100 Mobile Safari/537.36"
176
177
  sniffer = BrowserSniffer.new(user_agent)
177
-
178
+
178
179
  assert_equal ({
179
180
  name: 'Shopify Mobile',
180
181
  version: '8.12.0',
182
+ debug_mode: nil,
181
183
  build: '12005',
182
184
  sdk_version: '28',
183
185
  }), sniffer.browser_info
@@ -203,7 +205,8 @@ describe "Shopify agents" do
203
205
 
204
206
  assert_equal ({
205
207
  name: 'Shopify Mobile',
206
- version: '6.2.0 (debug)',
208
+ version: '6.2.0',
209
+ debug_mode: 'debug',
207
210
  build: '1',
208
211
  sdk_version: '25',
209
212
  }), sniffer.browser_info
@@ -551,13 +554,42 @@ describe "Shopify agents" do
551
554
  assert_equal sniffer.os_info, sniffer_with_suffix.os_info
552
555
  end
553
556
 
557
+ it "Shopify POS on Android can be sniffed (Native App) New Format" do
558
+ user_agent = "com.jadedpixel.pos Shopify POS/4.23.0/Android/12/google/Pixel 5/production MobileMiddlewareSupported"
559
+ sniffer = BrowserSniffer.new(user_agent)
560
+
561
+ user_agent_with_mal = "com.jadedpixel.pos Shopify POS/4.23.0-mal+30112/Android/12/google/Android SDK built for " \
562
+ "x86/development MobileMiddlewareSupported"
563
+ sniffer_with_suffix = BrowserSniffer.new(user_agent_with_mal)
564
+
565
+ assert_equal ({
566
+ name: 'Shopify POS',
567
+ version: '4.23.0',
568
+ }), sniffer.browser_info
569
+
570
+ assert_equal ({
571
+ type: :handheld,
572
+ }), sniffer.device_info
573
+
574
+ assert_equal ({
575
+ type: :android,
576
+ version: '12',
577
+ name: 'Android',
578
+ }), sniffer.os_info
579
+
580
+ assert_equal sniffer.browser_info, sniffer_with_suffix.browser_info
581
+ assert_equal sniffer.device_info, sniffer_with_suffix.device_info
582
+ assert_equal sniffer.os_info, sniffer_with_suffix.os_info
583
+ end
584
+
554
585
  it "Shopify Mobile in debug mode can be parsed" do
555
586
  user_agent = "Shopify Mobile/Android/6.0.0 (debug) (Build 1 with API 25 on Unknown Android SDK built for x86)"
556
587
  sniffer = BrowserSniffer.new(user_agent)
557
588
 
558
589
  assert_equal ({
559
590
  name: 'Shopify Mobile',
560
- version: '6.0.0 (debug)',
591
+ version: '6.0.0',
592
+ debug_mode: 'debug',
561
593
  build: '1',
562
594
  sdk_version: '25',
563
595
  }), sniffer.browser_info
@@ -580,7 +612,8 @@ describe "Shopify agents" do
580
612
 
581
613
  assert_equal ({
582
614
  name: 'Shopify Mobile',
583
- version: '6.0.0 (debug-push)',
615
+ version: '6.0.0',
616
+ debug_mode: 'debug-push',
584
617
  build: '1',
585
618
  sdk_version: '25',
586
619
  }), sniffer.browser_info
@@ -703,7 +736,7 @@ describe "Shopify agents" do
703
736
  COMPATIBLE_USER_AGENTS.each do |user_agent|
704
737
  it "user agent #{user_agent} is correctly marked as compatible" do
705
738
  sniffer = BrowserSniffer.new(user_agent)
706
-
739
+
707
740
  assert sniffer.same_site_none_compatible?
708
741
  end
709
742
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browser_sniffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-02 00:00:00.000000000 Z
11
+ date: 2021-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -79,7 +79,8 @@ homepage: https://github.com/Shopify/browser_sniffer
79
79
  licenses:
80
80
  - GPLv2
81
81
  - MIT
82
- metadata: {}
82
+ metadata:
83
+ allowed_push_host: https://rubygems.org
83
84
  post_install_message:
84
85
  rdoc_options: []
85
86
  require_paths:
@@ -95,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
96
  - !ruby/object:Gem::Version
96
97
  version: '0'
97
98
  requirements: []
98
- rubygems_version: 3.0.3
99
+ rubygems_version: 3.2.20
99
100
  signing_key:
100
101
  specification_version: 4
101
102
  summary: Parses user agent strings and boils it all down to a few simple classifications.