From 252dde05575226a67727bc088078575d1d6ab8ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Wed, 9 Feb 2022 10:22:00 +0100 Subject: [PATCH] =?utf8?q?Shop:=20Servernamen=20entweder=20mit=20Protokoll?= =?utf8?q?=20speichern=20oder=20Protokoll=20erg=C3=A4nzen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/Shop.pm | 3 ++- SL/ShopConnector/Shopware6.pm | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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'); -- 2.20.1