Skip to content

Commit cbe52aa

Browse files
committed
Set default value for $ub variable to prevent error.
1 parent f5a5526 commit cbe52aa

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/Message/AbstractRequest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ function getBrowser(){
596596
$bname = 'Unknown';
597597
$platform = 'Unknown';
598598
$version= "";
599+
$ub = 'Unknown';
599600

600601
//First get the platform?
601602
if (preg_match('/linux/i', $u_agent)) {
@@ -631,22 +632,20 @@ function getBrowser(){
631632
$known = array('Version', $ub, 'other');
632633
$pattern = '#(?<browser>' . join('|', $known) .
633634
')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
634-
if (!preg_match_all($pattern, $u_agent, $matches)) {
635-
// we have no matching number just continue
636-
}
635+
preg_match_all($pattern, $u_agent, $matches);
637636

638637
// see how many we have
639638
$i = count($matches['browser']);
640639
if ($i != 1) {
641640
//we will have two since we are not using 'other' argument yet
642641
//see if version is before or after the name
643642
if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){
644-
$version= $matches['version'][0];
643+
$version= (isset($matches['version'][0]) ? $matches['version'][0] : null);
645644
} else {
646-
$version= $matches['version'][1];
645+
$version= (isset($matches['version'][1]) ? $matches['version'][1] : null);
647646
}
648647
} else {
649-
$version= $matches['version'][0];
648+
$version= (isset($matches['version'][0]) ? $matches['version'][0] : null);
650649
}
651650

652651
// check if we have a number

0 commit comments

Comments
 (0)