Skip to content

Commit

Permalink
fix: Make -x, --xml-ua & --json-ua glpi-injector options equivalent
Browse files Browse the repository at this point in the history
Update --help option text
Closes #537
  • Loading branch information
g-bougard committed Nov 22, 2023
1 parent 599cf3c commit c3d31cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ netdiscovery/netinventory:
toolbox:
* fix #533: Fix Toolbox export buttons in inventory results

injector:
* fix #537: Make -x, --xml-ua & --json-ua options equivalent and update help text

1.6.1 Fri, 17 Nov 2023

core:
Expand Down
21 changes: 11 additions & 10 deletions bin/glpi-injector
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,16 @@ sub sendContent {
$content = uncompress($content);
}

if ($content =~ /^<\?xml/) {
undef $agentid;
if ($options->{"xml-ua"}) {
if ($options->{"xml-ua"} || $options->{"json-ua"}) {
if ($content =~ /^<\?xml/) {
undef $agentid;
my $xml = GLPI::Agent::XML->new(string => $content);
my $tree = $xml->dump_as_hash();
$useragent = $tree->{REQUEST}->{CONTENT}->{VERSIONCLIENT}
if $tree && $tree->{REQUEST} && $tree->{REQUEST}->{CONTENT} &&
$tree->{REQUEST}->{CONTENT}->{VERSIONCLIENT};
}
} elsif ($agentid || $content =~ /^{/) {
$agentid = newagentid() unless $agentid;
if ($options->{"xml-ua"} || $options->{"json-ua"}) {
} elsif ($agentid || $content =~ /^{/) {
$agentid = newagentid() unless $agentid;
my $json = decode_json($content);
$useragent = $json->{content}->{versionclient}
if $json && $json->{content} && $json->{content}->{versionclient};
Expand Down Expand Up @@ -299,7 +297,10 @@ glpi-injector - A tool to push inventory in an OCS Inventory or compatible serve
=head1 SYNOPSIS
glpi-injector [options] [--file <file>|--directory <directory>|--stdin|--useragent <user-agent>]
glpi-injector [-h|--help] [-R|--recursive] [-r|--remove] [-v|--verbose] [--debug]
[--useragent <user-agent>|-x|--xml-ua|--json-ua] [-C|--no-compression]
[--no-ssl-check] [--ssl-cert-file <private certificate file>] [[-P|--proxy] <proxy url>]
[[-f|--file] <file>|[-d|--directory] <directory>|--stdin] [-u|--url] <url>
Options:
-h --help this menu
Expand All @@ -312,8 +313,8 @@ glpi-injector [options] [--file <file>|--directory <directory>|--stdin|--userage
--debug debug mode to output server answer
--stdin read data from STDIN
--useragent set used HTTP User-Agent for POST
-x --xml-ua use Client version found in XML as User-Agent for POST
-x --json-ua use Client version found in JSON as User-Agent for POST
-x --xml-ua --json-ua
use Client version found in XML or JSON as User-Agent for POST
--no-ssl-check do not check server SSL certificate
--ssl-cert-file client certificate file
-C --no-compression don't compress sent XML inventories
Expand Down

0 comments on commit c3d31cf

Please sign in to comment.