diff --git a/.github/workflows/webmin.dev+webmin.yml b/.github/workflows/webmin.dev+webmin.yml index fcada5702..2b26d71c0 100644 --- a/.github/workflows/webmin.dev+webmin.yml +++ b/.github/workflows/webmin.dev+webmin.yml @@ -7,7 +7,6 @@ on: release: types: - published - - edited jobs: build: diff --git a/proc/syslog_logs.pl b/proc/syslog_logs.pl index a90b78abc..92010894d 100755 --- a/proc/syslog_logs.pl +++ b/proc/syslog_logs.pl @@ -7,7 +7,7 @@ require 'proc-lib.pl'; sub syslog_getlogs { if ($gconfig{'os_type'} =~ /-linux$/) { - return ( { 'cmd' => "dmesg", + return ( { 'cmd' => "dmesg -T", 'desc' => $text{'syslog_dmesg'}, 'active' => 1, } ); } diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl index 2ef672564..29dad3119 100755 --- a/web-lib-funcs.pl +++ b/web-lib-funcs.pl @@ -4058,7 +4058,7 @@ return " ". &group_chooser_button($_[0], 0, $_[2] || 0)."\n"; } -=head2 hlink(text, page, [module], [width], [height]) +=head2 hlink(text, page, [module], [width], [height], [tmpl]) Returns HTML for a link that when clicked on pops up a window for a Webmin help page. The parameters are : @@ -4073,6 +4073,8 @@ help page. The parameters are : =item height - Height of the help popup window. Defaults to 400 pixels. +=item tmpl - Hash ref of template variables to substitute in the help page. + The actual help pages are in each module's help sub-directory, in files with .html extensions. @@ -4086,8 +4088,8 @@ if (defined(&theme_hlink)) { } $width ||= $tconfig{'help_width'} || $gconfig{'help_width'} || 600; $height ||= $tconfig{'help_height'} || $gconfig{'help_height'} || 400; -my $params = $tmpl ? join("&", map { "tmpl_".&urlize($_)."=".&urlize($tmpl->{$_}) } keys %$tmpl) : ""; -return "$txt"; +my $params = $tmpl ? "?".join("&", map { "tmpl_".&urlize($_)."=".&urlize($tmpl->{$_}) } keys %$tmpl) : ""; +return "$txt"; } =head2 user_chooser_button(field, multiple, [form]) @@ -12968,47 +12970,60 @@ for(my $i=0; $i<@sp1 || $i<@sp2; $i++) { return 0; } -=head2 convert_to_json(data, [pretty]) +=head2 convert_to_json(data, [pretty], [raw-utf8]) Converts the given Perl data structure to encoded binary string =item data parameter is a hash/array reference =item if the output should be prettified +=item raw-utf8 parameter, if set to 1, encodes data using UTF-8 =cut sub convert_to_json { -eval "use JSON::PP"; -if (!$@) { - my ($data, $pretty) = @_; - my $json = JSON::PP->new; - $pretty = 0 if (!$pretty); - $json = $json->pretty($pretty); - $data ||= {}; - return $json->latin1->encode($data); +my ($data, $pretty, $raw_utf8) = @_; +my $json; + +if (eval { require JSON::XS }) { + $json = JSON::XS->new; + } +elsif (eval { require JSON::PP }) { + $json = JSON::PP->new; } else { - error("The JSON::PP Perl module is not available on your system : $@"); + error("Neither JSON::XS nor JSON::PP Perl module is available on your system"); } +$json->pretty(!!$pretty); +$data ||= {}; +return $raw_utf8 ? $json->utf8->encode($data) : $json->latin1->encode($data); } -=head2 convert_from_json(data) +=head2 convert_from_json(data, [raw-utf8]) Parses given JSON string =item data parameter is encoded JSON string +=item raw-utf8 parameter, if set, treats the input as raw UTF-8 + =cut sub convert_from_json { -eval "use JSON::PP"; -if (!$@) { - my ($json_text) = @_; - return JSON::PP->new->utf8->decode($json_text); +my ($json_text, $raw_utf8) = @_; + +my $json; +if (eval { require JSON::XS }) { + $json = JSON::XS->new; + } +elsif (eval { require JSON::PP }) { + $json = JSON::PP->new; } else { - error("The JSON::PP Perl module is not available on your system : $@"); + error("Neither JSON::XS nor JSON::PP Perl module is available on your system"); } + +$json = $json->utf8 if (!$raw_utf8); +return $json->decode($json_text); } =head2 print_json(data) diff --git a/webmin/os-eol-lib.pl b/webmin/os-eol-lib.pl index c75b74142..972afa9a0 100755 --- a/webmin/os-eol-lib.pl +++ b/webmin/os-eol-lib.pl @@ -64,10 +64,9 @@ foreach my $os (@eol_oses) { push(@eol_oses_data, @$fdata_json); } my $eol_oses_data = &convert_to_json(\@eol_oses_data); -&backquote_command("echo -n '$eol_oses_data' > $eol_cache_file 2>&1 ', $eol_cache_file) or die("Could not open OS EOL data file for writing: $!"); +print $fh $eol_oses_data; +close($fh) or die("Could not close OS EOL data file: $!"); } # eol_get_os_data()