From 8c0119fbb8f98b879ba08e18df3b39b276e91766 Mon Sep 17 00:00:00 2001 From: Lainow Date: Thu, 26 Feb 2026 14:16:14 +0100 Subject: [PATCH] Fix the computer contact injection when the corresponding value in the CSV file is empty --- CHANGELOG.md | 1 + inc/backendcsv.class.php | 33 ++++++++++++-------------------- inc/commoninjectionlib.class.php | 12 ++++++++++-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa15bb27..26509a5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Restored group selection in mappings - Fix special caracters malformed in translations - Fix error when displaying the additional information form +- Fix the `computer contact` injection when the corresponding value in the CSV file is empty ## [2.15.3] - 2025-12-22 diff --git a/inc/backendcsv.class.php b/inc/backendcsv.class.php index eb9b7585..b694c07d 100644 --- a/inc/backendcsv.class.php +++ b/inc/backendcsv.class.php @@ -98,27 +98,18 @@ public static function parseLine($fic, $data, $encoding = 1) $num = count($data); for ($c = 0; $c < $num; $c++) { - //If field is not the last, or if field is the last of the line and is not empty - - if ( - ($c < ($num - 1)) - || (($c == ($num - 1)) - && ($data[$num - 1] != PluginDatainjectionCommonInjectionLib::EMPTY_VALUE)) - ) { - $tmp = trim($DB->escape($data[$c])); - switch ($encoding) { - //If file is ISO8859-1 : encode the data in utf8 - case PluginDatainjectionBackend::ENCODING_ISO8859_1: - $csv[0][] = $tmp === '' || $tmp === '0' ? Toolbox::encodeInUtf8($tmp) : $tmp; - break; - - case PluginDatainjectionBackend::ENCODING_UFT8: - $csv[0][] = $tmp; - break; - - default: //PluginDatainjectionBackend :: ENCODING_AUTO : - $csv[0][] = PluginDatainjectionBackend::toUTF8($tmp); - } + $tmp = trim($DB->escape($data[$c])); + switch ($encoding) { + case PluginDatainjectionBackend::ENCODING_ISO8859_1: + $csv[0][] = $tmp === '' || $tmp === '0' ? Toolbox::encodeInUtf8($tmp) : $tmp; + break; + + case PluginDatainjectionBackend::ENCODING_UFT8: + $csv[0][] = $tmp; + break; + + default: + $csv[0][] = PluginDatainjectionBackend::toUTF8($tmp); } } return $csv; diff --git a/inc/commoninjectionlib.class.php b/inc/commoninjectionlib.class.php index 87f37eab..5a7f18d6 100644 --- a/inc/commoninjectionlib.class.php +++ b/inc/commoninjectionlib.class.php @@ -680,12 +680,20 @@ private function getFieldValue( break; case 'contact': - $id = $value != Dropdown::EMPTY_VALUE ? self::findContact($value, $this->entity) : Dropdown::EMPTY_VALUE; + if ($value === self::EMPTY_VALUE || $value == self::DROPDOWN_EMPTY_VALUE || $value === Dropdown::EMPTY_VALUE) { + $id = self::DROPDOWN_EMPTY_VALUE; + } else { + $id = self::findContact($value, $this->entity); + } $this->setValueForItemtype($itemtype, $linkfield, $id); break; case 'user': - $id = $value != Dropdown::EMPTY_VALUE ? self::findUser($value, $this->entity) : Dropdown::EMPTY_VALUE; + if ($value === self::EMPTY_VALUE || $value == self::DROPDOWN_EMPTY_VALUE || $value === Dropdown::EMPTY_VALUE) { + $id = self::DROPDOWN_EMPTY_VALUE; + } else { + $id = self::findUser($value, $this->entity); + } $this->setValueForItemtype($itemtype, $linkfield, $id); break;