This is because Windows clients won't import any configurations that
have spaces in the filename. Therefore we replace it and remove anything
else unwanted on the way.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
use Socket;
use Time::Local;
use Encode;
+use Unicode::Normalize;
require "${General::swroot}/graphs.pl";
return HTML::Entities::encode_entities($s);
}
+sub normalize($) {
+ my $s = shift;
+
+ # Remove any special characters
+ $s = &Unicode::Normalize::NFKD($s);
+
+ # Remove any whitespace and replace with dash
+ $s =~ s/\s+/\-/g;
+
+ return $s;
+}
+
sub cleanhtml {
my $outstring =$_[0];
$outstring =~ tr/,/ / if not defined $_[1] or $_[1] ne 'y';
# Open a new box
&Header::openbox('100%', '', "$Lang::tr{'wg peer configuration'}: $peer{'NAME'}");
+ # Make the filename for files
+ my $filename = &Header::normalize($peer{'NAME'}) . ".conf";
+
print <<END;
<div class="text-center">
<p>
</p>
<p>
- <a href="data:text/plain;base64,${config}" download="$peer{'NAME'}.conf">
+ <a href="data:text/plain;base64,${config}" download="${filename}">
$Lang::tr{'wg download configuration file'}
</a>
</p>