From 5f72cb63d446bcf185558ae68865395fd6bbedf6 Mon Sep 17 00:00:00 2001 From: Dario Corti Date: Sat, 3 Apr 2021 16:51:33 +0200 Subject: [PATCH] Restored original trailing spaces --- web-lib-funcs.pl | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl index 3382f7875..1afde39f7 100755 --- a/web-lib-funcs.pl +++ b/web-lib-funcs.pl @@ -146,7 +146,7 @@ Write out the contents of a hash as name=value lines. The parameters are : =cut sub write_file { -my ($file, +my ($file, $data_hash, $join_char, $sort, @@ -161,7 +161,7 @@ if ($sort || $gconfig{'sortconfigs'}) { foreach $k (sort keys %{$data_hash}) { (print ARFILE $k,$join,$data_hash->{$k},"\n") || &error(&text("efilewrite", $realfile, $!)); - + } } else { @@ -957,10 +957,19 @@ if ($gconfig{'extra_headers'}) { if (!$gconfig{'no_frame_options'}) { print "X-Frame-Options: SAMEORIGIN\n"; } -if (!$gconfig{'no_content_security_policy'}) { - print "Content-Security-Policy: script-src 'self' 'unsafe-inline' 'unsafe-eval'; frame-src 'self'; child-src 'self'\n"; +if (!$gconfig{'no_content_security_policy'} && + $gconfig{'extra_headers'} !~ /Content-Security-Policy:/) { + if ($tconfig{'csp_headers'}) { + print "Content-Security-Policy: $tconfig{'csp_headers'}\n"; + } + else { + print "Content-Security-Policy: script-src 'self' 'unsafe-inline' 'unsafe-eval'; frame-src 'self'; child-src 'self'\n"; + } } print "X-Content-Type-Options: nosniff\n"; +if ($tconfig{'nolinks'}) { + print "X-no-links: 1\n"; + } if (defined($cs)) { print "Content-type: $mt; Charset=$cs\n\n"; } @@ -1652,8 +1661,8 @@ elsif ($ENV{'REQUEST_URI'} =~ /json-error=1/) { my $error_message = join(",", @_); my $error = ($error_what . $error_message); %jerror = (error => $error, - error_fatal => 1, - error_what => $error_what, + error_fatal => 1, + error_what => $error_what, error_message => $error_message ); print_json(\%jerror); @@ -1936,9 +1945,9 @@ sub make_date { &load_theme_library(); if (defined(&theme_make_date) && - !$main::theme_prevent_make_date && + !$main::theme_prevent_make_date && (($main::header_content_type eq "text/html" && - $main::webmin_script_type eq "web") || + $main::webmin_script_type eq "web") || $main::theme_allow_make_date)) { return &theme_make_date(@_); } @@ -5292,7 +5301,7 @@ if (!defined($auto)) { my $glangauto = $gconfig{'langauto'}; if (defined($glangauto)) { $auto = $glangauto; - } + } else { my ($clanginfo) = grep { $_->{'lang'} eq $current_lang } &list_languages(); @@ -5328,14 +5337,14 @@ my ($dir) = ($_[1] || "lang"); foreach my $o (@lang_order_list) { my $ok = &read_file_cached_with_stat("$root/$dir/$o", \%text); my $ok_auto; - $ok_auto = &read_file_cached_with_stat("$root/$dir/$o.auto", \%text) + $ok_auto = &read_file_cached_with_stat("$root/$dir/$o.auto", \%text) if ($auto && -r "$root/$dir/$o.auto"); return () if (!$ok && !$ok_auto && $o eq $default_lang); } if ($ol) { foreach my $o (@lang_order_list) { &read_file_cached("$root/$ol/$o", \%text); - &read_file_cached("$root/$ol/$o.auto", \%text) + &read_file_cached("$root/$ol/$o.auto", \%text) if ($auto && -r "$root/$ol/$o.auto"); } } @@ -8997,10 +9006,10 @@ if (!$ucd) { =head2 nice_size(bytes, [minimal], [decimal]) -Converts a number of bytes into a number followed by a suffix like GiB, -MiB or kiB (or GB, MB, kB, if optional parameter [decimal] is set to true). -Output value is clipped to two decimal digits. The optional [minimal] parameter -sets the smallest units to use - so you could pass 1024*1024 to never show +Converts a number of bytes into a number followed by a suffix like GiB, +MiB or kiB (or GB, MB, kB, if optional parameter [decimal] is set to true). +Output value is clipped to two decimal digits. The optional [minimal] parameter +sets the smallest units to use - so you could pass 1024*1024 to never show bytes or kB. =cut @@ -10546,7 +10555,7 @@ if ($fsize <= $limit || !$limit) { # Starting and ending number of bytes to read my $split = !$opts->{'head'} && !$opts->{'tail'}; -# Make it a half of a limit, to +# Make it a half of a limit, to # grab both head and tail eaquly $limit = $limit / 2 if ($split); @@ -11434,7 +11443,7 @@ print convert_to_json(@_); =head2 get_referer_relative() -Returns relative URL based on referer omitting origin part. +Returns relative URL based on referer omitting origin part. Should be used instead for redirects with submitted forms =cut @@ -11450,7 +11459,7 @@ return $referer; =head2 get_webmin_email_url([module], [cgi], [force-default], [force-host]) -Returns the base URL for accessing this Webmin system, for use in URLs. +Returns the base URL for accessing this Webmin system, for use in URLs. =cut sub get_webmin_email_url