25
25
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26
26
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
27
*
28
- * @version 2.0
29
- * @last-modified March 12 , 2021
28
+ * @version 2.1
29
+ * @last-modified April 6 , 2021
30
30
* @link https://github.com/foroco/php-browser-detection
31
31
*/
32
32
@@ -313,7 +313,7 @@ private function getResult()
313
313
{
314
314
$ this ->result_os_name = 'Windows ' ;
315
315
$ matches = $ this ->match_ua ('/Windows ([ .a-zA-Z0-9]+)[; \\)]/ ' );
316
- $ version = $ matches [1 ];
316
+ $ version = is_array ( $ matches) ? $ matches [1 ] : 0 ;
317
317
if ($ version === 'NT 10.0 ' ) $ this ->result_os_version = '10 ' ;
318
318
if ($ version === 'NT 6.4 ' ) $ this ->result_os_version = '10 ' ;
319
319
if ($ version === 'NT 6.3 ' ) $ this ->result_os_version = '8.1 ' ;
@@ -369,8 +369,8 @@ private function getResult()
369
369
if ($ this ->match_ua ('Mac OS X ' ))
370
370
{
371
371
$ matches = $ this ->match_ua ('/Mac OS X (\d+)[_.](\d+)/ ' );
372
- $ version = $ matches [1 ];
373
- $ version_minor = $ matches [2 ];
372
+ $ version = is_array ( $ matches) ? $ matches [1 ] : 0 ;
373
+ $ version_minor = is_array ( $ matches) ? $ matches [2 ] : 0 ;
374
374
375
375
if ($ version == 11 ) $ version_minor = 16 ;
376
376
if (!empty ($ version_minor ))
@@ -526,11 +526,11 @@ private function getResult()
526
526
$ this ->result_os_version = 0 ;
527
527
$ this ->result_os_name = 'Android ' ;
528
528
$ matches = $ this ->match_ua ('/Android(?: |\-)([0-9]+\.[0-9]+)/ ' );
529
- $ this ->result_os_version = ( float )$ matches [1 ];
529
+ $ this ->result_os_version = is_array ( $ matches ) ? ( float )$ matches [1 ] : 0 ;
530
530
if (empty ($ this ->result_os_version ))
531
531
{
532
532
$ matches = $ this ->match_ua ('/Android(?: |\-)(\d+)/ ' );
533
- $ this ->result_os_version = ( float )$ matches [1 ];
533
+ $ this ->result_os_version = is_array ( $ matches ) ? ( float )$ matches [1 ] : 0 ;
534
534
}
535
535
$ this ->result_os_family = 'android ' ;
536
536
$ os_need_continue = FALSE ;
@@ -543,8 +543,8 @@ private function getResult()
543
543
$ this ->result_os_version = 0 ;
544
544
$ this ->result_os_name = 'iOS ' ;
545
545
$ matches = $ this ->match_ua ('/\sOS\s(\d+)[_.](\d+)/ ' );
546
- $ version = $ matches [1 ];
547
- $ version_minor = $ matches [2 ];
546
+ $ version = is_array ( $ matches) ? $ matches [1 ] : 0 ;
547
+ $ version_minor = is_array ( $ matches) ? $ matches [2 ] : 0 ;
548
548
if (!empty ($ version )) $ this ->result_os_version = floatval ($ version .'. ' .$ version_minor );
549
549
$ this ->result_os_family = 'macintosh ' ;
550
550
$ os_need_continue = FALSE ;
@@ -789,7 +789,7 @@ private function getResult()
789
789
$ this ->result_browser_version = 0 ;
790
790
$ matches = $ this ->match_ua ('/(Chrome|Chromium|CriOS|CrMo)\/([0-9]+)\./ ' );
791
791
$ this ->result_browser_name = 'Chrome ' ;
792
- if ($ matches [1 ]==='Chromium ' ) $ this ->result_browser_name = 'Chromium ' ;
792
+ if (! empty ( $ matches [ 1 ]) && $ matches [1 ]==='Chromium ' ) $ this ->result_browser_name = 'Chromium ' ;
793
793
if (!empty ($ matches [2 ])) $ this ->result_browser_version = (int )$ matches [2 ];
794
794
$ this ->result_browser_chromium_version = $ this ->result_browser_version ;
795
795
if ($ this ->match_ua ('CriOS/ ' )) $ this ->result_browser_chromium_version = 0 ;
@@ -855,7 +855,7 @@ private function getResult()
855
855
$ this ->result_browser_name = $ browser_list_va [0 ];
856
856
$ matches = $ this ->match_ua ($ browser_list_va [2 ]);
857
857
$ matches_n = intval ($ browser_list_va [3 ]);
858
- $ this ->result_browser_version = ( float )$ matches [$ matches_n ];
858
+ $ this ->result_browser_version = is_array ( $ matches ) ? ( float )$ matches [$ matches_n ] : 0 ;
859
859
if (!empty ($ this ->result_browser_version ))
860
860
{
861
861
$ browser_need_continue = FALSE ;
@@ -873,8 +873,13 @@ private function getResult()
873
873
{
874
874
$ this ->result_browser_gecko_version = 0 ;
875
875
$ match = $ this ->match_ua ('/\srv:([0-9]+\.[0-9]+)(?:[.0-9a-z]+)?(?:\;\s\w+|)\)\sGecko\/[.0-9]+\s/ ' );
876
- if ($ match [1 ]>=5 ) $ match [1 ] = intval ($ match [1 ]);
877
- else $ match [1 ] = (float )$ match [1 ];
876
+
877
+ if (is_array ($ match ))
878
+ {
879
+ if ($ match [1 ]>=5 ) $ match [1 ] = intval ($ match [1 ]);
880
+ else $ match [1 ] = (float )$ match [1 ];
881
+ }
882
+
878
883
if (!empty ($ match [1 ])) $ this ->result_browser_gecko_version = $ match [1 ];
879
884
else
880
885
{
@@ -996,7 +1001,7 @@ private function getResult()
996
1001
$ this ->result_browser_name = $ browser_list_va [0 ];
997
1002
$ matches = $ this ->match_ua ($ browser_list_va [2 ]);
998
1003
$ matches_n = intval ($ browser_list_va [3 ]);
999
- $ this ->result_browser_version = ( float )$ matches [$ matches_n ];
1004
+ $ this ->result_browser_version = is_array ( $ matches ) ? ( float )$ matches [$ matches_n ] : 0 ;
1000
1005
1001
1006
// Safari old version conversion
1002
1007
@@ -1167,7 +1172,7 @@ private function getResult()
1167
1172
$ this ->result_browser_name = $ browser_list_va [0 ];
1168
1173
$ matches = $ this ->match_ua ($ browser_list_va [2 ]);
1169
1174
$ matches_n = intval ($ browser_list_va [3 ]);
1170
- $ this ->result_browser_version = ( float )$ matches [$ matches_n ];
1175
+ $ this ->result_browser_version = is_array ( $ matches ) ? ( float )$ matches [$ matches_n ] : 0 ;
1171
1176
1172
1177
if (!empty ($ this ->result_browser_version ))
1173
1178
{
0 commit comments