Skip to content

Commit 33090aa

Browse files
authored
Fix(Core): fix file upload (#517)
* Fix(Core): fix file upload * fix CS * fix CS * fix
1 parent d9abc7c commit 33090aa

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [UNRELEASED]
9+
10+
### Fixed
11+
12+
- Fix file upload
13+
14+
815
## [2.15.0] - 2025-09-30
916

1017
### Added

inc/backend.class.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* @link https://github.com/pluginsGLPI/datainjection
2828
* -------------------------------------------------------------------------
2929
*/
30-
use Glpi\Exception\Http\HttpException;
30+
3131

3232
use function Safe\preg_match;
3333

@@ -78,12 +78,17 @@ public static function getHeader($injectionData, $header_present)
7878
**/
7979
public static function getInstance($type)
8080
{
81+
$allowedBackends = [
82+
'csv' => PluginDatainjectionBackendcsv::class,
83+
];
8184

82-
$class = 'PluginDatainjectionBackend' . $type;
83-
if (!is_a($class, CommonDBTM::class, true)) {
84-
throw new HttpException(500, 'Class ' . $class . ' is not a valid class');
85+
if (!isset($allowedBackends[$type])) {
86+
throw new InvalidArgumentException("Unknown backend type: $type");
8587
}
86-
return new $class();
88+
89+
return new $allowedBackends[$type]();
90+
91+
8792
}
8893

8994

0 commit comments

Comments
 (0)