From cacfba9a37b521375defb6f156f091bfd9346800 Mon Sep 17 00:00:00 2001
From: Michael Newton <miken32@gmail.com>
Date: Wed, 2 Apr 2025 16:47:30 -0600
Subject: [PATCH] don't pass null to trim()

---
 Components/Outboundrouting.php | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Components/Outboundrouting.php b/Components/Outboundrouting.php
index 663305239..82e8023d2 100644
--- a/Components/Outboundrouting.php
+++ b/Components/Outboundrouting.php
@@ -13,7 +13,7 @@ public function add($name, $outcid, $outcid_mode, $password, $emergency_route, $
 		$sth->execute(array(
 			":name" => $name,
 			":outcid" => $outcid,
-			":outcid_mode" => trim($outcid) == '' ? '' : $outcid_mode,
+			":outcid_mode" => trim($outcid ?? '') === '' ? '' : $outcid_mode,
 			":password" => $password,
 			":emergency_route" => strtoupper($emergency_route),
 			":intracompany_route" => strtoupper($intracompany_route),
@@ -44,7 +44,7 @@ public function editById($route_id, $name, $outcid, $outcid_mode, $password, $em
 			":route_id" => $route_id,
 			":name" => $name,
 			":outcid" => $outcid,
-			":outcid_mode" => trim($outcid) == '' ? '' : $outcid_mode,
+			":outcid_mode" => trim($outcid ?? '') === '' ? '' : $outcid_mode,
 			":password" => $password,
 			":emergency_route" => strtoupper($emergency_route),
 			":intracompany_route" => strtoupper($intracompany_route),
@@ -170,10 +170,10 @@ public function updatePatterns($id, $patterns, $delete = false){
 			dbug(sprintf(_("All the patterns for route id %s were NOT unique which can cause unexpected behavior This may be unallowed in the future."),$id));
 		}
 		foreach ($patterns as $pattern) {
-			$match_pattern_prefix = preg_replace($filter, '', strtoupper(trim($pattern['match_pattern_prefix'])));
-			$match_pattern_pass = preg_replace($filter, '', strtoupper(trim($pattern['match_pattern_pass'])));
-			$match_cid = preg_replace($filter, '', strtoupper(trim($pattern['match_cid'])));
-			$prepend_digits = preg_replace($filter, '', strtoupper(trim($pattern['prepend_digits'])));
+			$match_pattern_prefix = preg_replace($filter, '', strtoupper(trim($pattern['match_pattern_prefix'] ?? '')));
+			$match_pattern_pass = preg_replace($filter, '', strtoupper(trim($pattern['match_pattern_pass'] ?? '')));
+			$match_cid = preg_replace($filter, '', strtoupper(trim($pattern['match_cid'] ?? '')));
+			$prepend_digits = preg_replace($filter, '', strtoupper(trim($pattern['prepend_digits'] ?? '')));
 
 			if ($match_pattern_prefix . $match_pattern_pass . $match_cid == '') {
 				continue;