Skip to content

Commit 7afecf7

Browse files
committed
Merge branch 'release/2.5.1'
2 parents f6b5dd7 + 7c69adf commit 7afecf7

15 files changed

+1588
-181
lines changed

.tx/config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[main]
22
host = https://www.transifex.com
33

4-
[glpi-plugins-datainjection.datainjection-243pot]
4+
[glpi-plugin-datainjection.datainjection-243pot]
55
file_filter = locales/<lang>.po
66
source_file = locales/datainjection.pot
77
source_lang = en

ajax/dropdownMandatory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@
3636
}
3737

3838
Session::checkCentralAccess();
39-
PluginDatainjectionInjectionType::showMandatoryCheckBox($_POST);
39+
PluginDatainjectionInjectionType::showMandatoryCheckbox($_POST);

datainjection.xml

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
<author>Xavier Caillaud</author>
2626
</authors>
2727
<versions>
28+
<version>
29+
<num>2.5.1</num>
30+
<compatibility>9.2</compatibility>
31+
</version>
2832
<version>
2933
<num>2.5.0</num>
3034
<compatibility>9.2</compatibility>

hook.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function plugin_datainjection_install() {
4848
global $DB;
4949

5050
include_once GLPI_ROOT."/plugins/datainjection/inc/profile.class.php";
51-
$migration = new Migration('2.5.0');
51+
$migration = new Migration(PLUGIN_DATAINJECTION_VERSION);
5252

5353
switch (plugin_datainjection_needUpdateOrInstall()) {
5454
case -1 :

inc/backendcsv.class.php

+8
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ function getNumberOfLines() {
198198
function openFile() {
199199

200200
$this->file_handler = fopen($this->file, 'r');
201+
202+
// Check if file starts with BOM.
203+
// 1. If BOM found, keep the handler moved to 4th char to not include it in data.
204+
// 2. If no BOM found, rewind to start of file.
205+
$hasBOM = fread($this->file_handler, 3) === pack('CCC', 0xEF, 0xBB, 0xBF);
206+
if (!$hasBOM) {
207+
fseek($this->file_handler, 0);
208+
}
201209
}
202210

203211

inc/injectiontype.class.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ static function dropdownLinkedTypes($mapping_or_info, $options=array()) {
106106

107107
$p['primary_type'] = '';
108108
$p['itemtype'] = self::NO_VALUE;
109-
$p['mapping_or_info'] = json_encode($mapping_or_info->fields);
109+
// Use hex code for all special chars to prevent problems when adding/stripping slashes
110+
$p['mapping_or_info'] = json_encode(
111+
$mapping_or_info->fields,
112+
JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP
113+
);
110114
$p['called_by'] = get_class($mapping_or_info);
111115
$p['fields_update'] = true;
112116
foreach ($options as $key => $value) {
@@ -290,14 +294,14 @@ static function testBasicEqual($name, $option=array()) {
290294
**/
291295
static function showMandatoryCheckbox($options=array()) {
292296

293-
//json adds more \ char than needed : when $options['mapping_or_info']['name'] contains a '
294-
//json_decode fails to decode it !
295-
$options['mapping_or_info'] = str_replace("\\", "", $options['mapping_or_info']);
297+
// Received data has been slashed.
298+
$options = Toolbox::stripslashes_deep($options);
296299

297300
if ($options['need_decode']) {
301+
// JSON data has been slashed twice, stripslashes has to be done a second time.
298302
$mapping_or_info = json_decode(
299-
Toolbox::stripslashes_deep($options['mapping_or_info']),
300-
true
303+
Toolbox::stripslashes_deep($options['mapping_or_info']),
304+
true
301305
);
302306
} else {
303307
$mapping_or_info = $options['mapping_or_info'];

locales/cs_CZ.mo

8.26 KB
Binary file not shown.

0 commit comments

Comments
 (0)