Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
33 changes: 12 additions & 21 deletions inc/backendcsv.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 10 additions & 2 deletions inc/commoninjectionlib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down