Skip to content
Permalink
Browse files
shibui-2341 better url encoding, utf8 encoding of names
  • Loading branch information
Sean Porth committed Sep 12, 2022
1 parent 7331279 commit 1f7a8ff6b116e8c72b5bd6b0b28c873f1cfc5a9c
Showing 3 changed files with 11 additions and 7 deletions.
@@ -42,6 +42,6 @@ If you prefer to build the image yourself, `cd docker-build;docker build -t unic

### running without docker ###
The docker-build/shibui-md-upload.pl script can be run manually.
Depending on OS you may need to install some additional non dist Perl modules. REST::Client , XML::LibXML , JSON , Config::File
Depending on OS you may need to install some additional non dist Perl modules. REST::Client , XML::LibXML , JSON , Config::File , URI::Encode
`perl shibui-md-upload.pl -c <path to upload.conf> -m <path to metadata location> -e (enable metadata source after upload)`

@@ -3,7 +3,7 @@ MAINTAINER sporth@unicon.net

RUN apt-get clean \
&& apt-get -y update \
&& apt-get install -y librest-client-perl libconfig-file-perl jq libxml-libxml-perl libjson-perl
&& apt-get install -y librest-client-perl libconfig-file-perl jq libxml-libxml-perl libjson-perl liburi-encode-perl

WORKDIR /opt
COPY shibui-md-upload.pl /opt/shibui-md-upload.pl
@@ -12,6 +12,7 @@ use XML::LibXML;
use XML::LibXML::XPathContext;
use Encode;
use JSON;
use URI::Encode;

##process arguments
our ($opt_e,$opt_m,$opt_c);
@@ -201,10 +202,13 @@ sub call_api {
my $xml = shift;
my $enable = shift;
my ($params,$code,$result);
my $encoder = URI::Encode->new({encode_reserved => 1});

my $utf8 = encode_utf8($xml);
my $utf8_name = encode_utf8($name);
my $ename = $encoder->encode($name);

$params = "?spName=$name";
$params = "?spName=$ename";
$params .= "&enableService=true" if ($enable);

$client->addHeader('Content-Type', "application/xml; charset='utf8'");
@@ -226,18 +230,18 @@ sub call_api {
my $eresult = $client->responseContent();

if ($ecode == 200 || $ecode == 201) {
print "$ecode: entity $name uploaded sucessfully and enabled\n";
print "$ecode: entity $utf8_name uploaded sucessfully and enabled\n";
} else {
print "$ecode: entity $name uploaded sucessfully but enabling failed:\n";
print "$ecode: entity $utf8_name uploaded sucessfully but enabling failed:\n";
open(my $pipe, '|-', "jq .");
print $pipe $eresult;
}

} else {
print "$code: entity $name uploaded sucessfully\n";
print "$code: entity $utf8_name uploaded sucessfully\n";
}
} elsif ($code == 409) {
print "$code: entity $name already exists\n";
print "$code: entity $utf8_name already exists\n";
} elsif ($code == 500) {
print "$code: $result\n";
} else {

0 comments on commit 1f7a8ff

Please sign in to comment.