From 2580c06cb74b7f502d7cbe4249dc17d8d1f8126e Mon Sep 17 00:00:00 2001 From: Vincent Li Date: Thu, 3 Jul 2025 18:01:07 +0000 Subject: [PATCH] wireguard.cgi: missed normalize sub in header.pl commit 37174e29de670a33f9be4b90c88b0a96c695dad1 Author: Michael Tremer Date: Fri Sep 27 17:55:46 2024 +0200 wireguard.cgi: Normalize filenames 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 Signed-off-by: Vincent Li --- config/cfgroot/header.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl index df7b0f009..7c1935087 100644 --- a/config/cfgroot/header.pl +++ b/config/cfgroot/header.pl @@ -16,6 +16,7 @@ use File::Basename; use HTML::Entities(); use Socket; use Time::Local; +use Unicode::Normalize; our %color = (); &General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color); @@ -363,6 +364,18 @@ sub escape($) { 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';