From: Jan Büren Date: Wed, 9 Feb 2022 09:22:00 +0000 (+0100) Subject: Shop: Servernamen entweder mit Protokoll speichern oder Protokoll ergänzen X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~218^2~6 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=252dde05575226a67727bc088078575d1d6ab8ce;p=kivitendo-erp.git Shop: Servernamen entweder mit Protokoll speichern oder Protokoll ergänzen --- diff --git a/SL/DB/Shop.pm b/SL/DB/Shop.pm index 55f81e551..c5e652aae 100644 --- a/SL/DB/Shop.pm +++ b/SL/DB/Shop.pm @@ -21,7 +21,8 @@ sub validate { push @errors, $::locale->text('The path is missing.') unless $self->{path}; push @errors, $::locale->text('The Host Name is missing') unless $self->{server}; push @errors, $::locale->text('The Host Name seems invalid') unless $self->{server} =~ m/[0-9A-Za-z].\.[0-9A-Za-z]/; - push @errors, $::locale->text('The Proxy Name seems invalid') unless $self->{proxy} =~ m/[0-9A-Za-z].\.[0-9A-Za-z]/; + push @errors, $::locale->text('The Protocol for Host Name seems invalid (expected: http:// or https://)!') + if ($self->{server} =~ m/:/ && $self->{server} !~ m/(^https:\/\/|^http:\/\/)/); push @errors, $::locale->text('The Proxy Name seems invalid') . $self->{proxy} . ':' unless !$self->{proxy} || $self->{proxy} =~ m/[0-9A-Za-z].\.[0-9A-Za-z]/; push @errors, $::locale->text('Orders to fetch neeeds a positive Integer') unless $self->{orders_to_fetch} > 0; diff --git a/SL/ShopConnector/Shopware6.pm b/SL/ShopConnector/Shopware6.pm index 38ec37f97..bd5432914 100644 --- a/SL/ShopConnector/Shopware6.pm +++ b/SL/ShopConnector/Shopware6.pm @@ -709,10 +709,10 @@ sub set_orderstatus { sub init_connector { my ($self) = @_; - my $client = REST::Client->new(host => $self->config->server); + my $protocol = $self->config->server =~ /(^https:\/\/|^http:\/\/)/ ? '' : $self->config->protocol . '://'; + my $client = REST::Client->new(host => $protocol . $self->config->server); $client->getUseragent()->proxy([$self->config->protocol], $self->config->proxy) if $self->config->proxy; - $client->addHeader('Content-Type', 'application/json'); $client->addHeader('charset', 'UTF-8'); $client->addHeader('Accept', 'application/json');