From: Robert Kaiser <kairo@kairo.at>
Date: Sun, 3 Nov 2024 00:06:21 +0000 (+0100)
Subject: make sure we don't get a null uastring
X-Git-Url: https://git-public.kairo.at/?a=commitdiff_plain;h=2e4c5351ac0b94b2e80da9506f93d979fc69dd72;p=php-utility-classes.git

make sure we don't get a null uastring
---

diff --git a/classes/useragent.php-class b/classes/useragent.php-class
index 190e539..c64117f 100755
--- a/classes/useragent.php-class
+++ b/classes/useragent.php-class
@@ -106,11 +106,12 @@ class userAgent {
     }
     else {
       // read raw UA string
-      $this->uastring = $_SERVER['HTTP_USER_AGENT'];
+      $this->uastring = ($_SERVER['HTTP_USER_AGENT'] ?? '');
     }
 
     // get UA brand and version
-    $this->brand = 'Unknown'; $this->version = null;
+    $this->brand = 'Unknown';
+    $this->version = null;
     // find reasonable defaults
     if (preg_match('|([0-9a-zA-Z\.:()_ -]+)/(\d[0-9a-zA-Z\._+-]*)|', $this->uastring, $regs)) {
       $this->brand = trim($regs[1]);