From 95701a643820a668c473efdda54db601fdf88918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 9 Sep 2024 00:08:15 +0200 Subject: [PATCH] Use unicode modifier for preg_match to avoid problems when parameters contain non-unicode strings --- .../InfoProviderSystem/Providers/OEMSecretsProvider.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Services/InfoProviderSystem/Providers/OEMSecretsProvider.php b/src/Services/InfoProviderSystem/Providers/OEMSecretsProvider.php index 1da5b30c..b5a29c60 100644 --- a/src/Services/InfoProviderSystem/Providers/OEMSecretsProvider.php +++ b/src/Services/InfoProviderSystem/Providers/OEMSecretsProvider.php @@ -1194,7 +1194,7 @@ class OEMSecretsProvider implements InfoProviderInterface $result['value_text'] = trim($textValue); } else { // Check if the value is numeric with a unit - if (preg_match('/^([\+\-]?\d+(\.\d+)?)([a-zA-Z%°]+)?$/', $value, $matches)) { + if (preg_match('/^([\+\-]?\d+(\.\d+)?)([a-zA-Z%°]+)?$/u', $value, $matches)) { // It is a number with or without a unit $result['value_typ'] = isset($matches[1]) ? (float)$matches[1] : null; $result['unit'] = $matches[3] ?? null; @@ -1234,7 +1234,7 @@ class OEMSecretsProvider implements InfoProviderInterface $value_typ = null; // Search for the number + unit pattern - if (preg_match('/^([\+\-]?\d+(\.\d+)?)([a-zA-Z%°]+)?$/', $value1, $matches)) { + if (preg_match('/^([\+\-]?\d+(\.\d+)?)([a-zA-Z%°]+)?$/u', $value1, $matches)) { $value_typ = $matches[1]; $unit = $matches[3] ?? null; } @@ -1245,7 +1245,7 @@ class OEMSecretsProvider implements InfoProviderInterface ]; if ($value2 !== null) { - if (preg_match('/^([\+\-]?\d+(\.\d+)?)([a-zA-Z%°]+)?$/', $value2, $matches2)) { + if (preg_match('/^([\+\-]?\d+(\.\d+)?)([a-zA-Z%°]+)?$/u', $value2, $matches2)) { $result['value_min'] = $value_typ; $result['value_max'] = $matches2[1]; $result['unit'] = $matches2[3] ?? $unit; // If both values have the same unit, we keep it