Skip to content

A free open source IT asset/license management system

Ensure we don't call preg_split() with a null as the second parameter

Brady Wetheringtonde3ebfecfe16
diff --git a/app/Http/Requests/SettingsSamlRequest.php b/app/Http/Requests/SettingsSamlRequest.php
index 8f02d64f03..2ab876141a 100644
--- a/app/Http/Requests/SettingsSamlRequest.php
+++ b/app/Http/Requests/SettingsSamlRequest.php
@@ -62,7 +62,7 @@ class SettingsSamlRequest extends FormRequest
$custom_privateKey = '';
$custom_x509certNew = '';
if (! empty($this->input('saml_custom_settings'))) {
- $req_custom_settings = preg_split('/\r\n|\r|\n/', $this->input('saml_custom_settings'));
+ $req_custom_settings = preg_split('/\r\n|\r|\n/', $this->input('saml_custom_settings', ''));
$custom_settings = [];
foreach ($req_custom_settings as $custom_setting) {
diff --git a/app/Models/CustomField.php b/app/Models/CustomField.php
index dfa4971367..81eff9b4cd 100644
--- a/app/Models/CustomField.php
+++ b/app/Models/CustomField.php
@@ -307,7 +307,7 @@ class CustomField extends Model
public function formatFieldValuesAsArray()
{
$result = [];
- $arr = preg_split('/\\r\\n|\\r|\\n/', $this->field_values);
+ $arr = preg_split('/\\r\\n|\\r|\\n/', $this->field_values ?? '');
if (($this->element != 'checkbox') && ($this->element != 'radio')) {
$result[''] = 'Select '.strtolower($this->format);
diff --git a/app/Services/Saml.php b/app/Services/Saml.php
index 860ec76171..222c2c2ea3 100644
--- a/app/Services/Saml.php
+++ b/app/Services/Saml.php
@@ -209,7 +209,7 @@ class Saml
}
}
- $custom_settings = preg_split('/\r\n|\r|\n/', $setting->saml_custom_settings);
+ $custom_settings = preg_split('/\r\n|\r|\n/', $setting->saml_custom_settings ?? '');
if ($custom_settings) {
foreach ($custom_settings as $custom_setting) {
$split = explode('=', $custom_setting, 2);