Compare commits

..

9 Commits

Author SHA1 Message Date
Ilia Ross
3885773f6e Fix to correctly test if hash ref is empty 2023-11-07 21:32:37 +02:00
Ilia Ross
dc3ed53c43 Fix to re-use un_urlize API 2023-11-07 11:48:45 +02:00
Ilia Ross
24ca182b18 Fix to correctly extract config query for Save and Next 2023-11-07 02:46:56 +02:00
Ilia Ross
54c7856672 Fix to also automatically detect if prefix was loaded 2023-11-07 02:14:01 +02:00
Ilia Ross
9b3fb73aea Fix missing semicolon 2023-11-07 02:04:14 +02:00
Ilia Ross
692c9cc5e1 Fix to correctly process params
(remove leaked debug code)
2023-11-07 01:40:38 +02:00
Ilia Ross
62bcd25eb9 Add support for preserving config params in Legacy Theme 2023-11-06 22:27:00 +02:00
Ilia Ross
a6d23844ce Add support for preserving config params in Framed Theme 2023-11-06 22:17:12 +02:00
Ilia Ross
a9cd02aa6d Add API to preserve module params as going to config page 2023-11-06 22:16:30 +02:00
10 changed files with 104 additions and 22 deletions

View File

@@ -1,11 +1,5 @@
## Changelog
#### 2.105 (November 09, 2023)
* Fix param to read only headers [sourceforge.net/usermin-bugs#501](https://sourceforge.net/p/webadmin/usermin-bugs/501/)
* Fix not to set `reuse` flag on initial Let's Encrypt request
* Fix to correctly escape mail file names upon deletion
* Fix index field in cache file in BIND DNS module
#### 2.104 (October 16, 2023)
* Add support for numbered and bulleted lists in email HTML editor
* Add ability to display active file locks in `Webmin Configuration ⇾ File Locking` page

View File

@@ -407,5 +407,89 @@ if (-r $module_prefs_conf) {
}
}
# read_config_params(url, insert-prefix)
# Parses the URL parameters from a URL, and returns a hash ref
sub read_config_params
{
my ($url, $pref) = @_;
# Extract the part of the URL after the question mark
my ($query_string) = $url =~ /\?(.*)$/;
my %params;
# Split the query string on '&' to get the individual key-value pairs
for my $pair (split(/&/, $query_string)) {
my ($key, $value) = split /=/, $pair;
$value = &un_urlize($value);
my $param_prefix = $pref ? "_cparam-" : "";
$params{"$param_prefix$key"} = $value;
}
return \%params;
}
# print_config_posted_params()
# Prints hidden fields for all the parameters in the referrer URL
sub print_config_posted_params
{
my $env_referer = $ENV{'HTTP_REFERER'};
my $params_referer = &read_config_params($env_referer);
my $params_url = &read_config_params($ENV{'REQUEST_URI'});
my $params = { %$params_referer, %$params_url };
my @params;
if (%$params) {
foreach my $param (keys %{$params}) {
my $param_prefix = "_cparam-";
if ($param =~ /section|module|mode|section_next|nnext|nprev|xnavigation/ ||
!$params->{$param} || $env_referer =~ /$param_prefix$param=/ ||
$params_url =~ /$param_prefix$param=/ || &indexof($param, @params) > -1) {
next;
}
$param_prefix = "" if ($param =~ /^$param_prefix/);
push(@params, $param);
print &ui_hidden("$param_prefix$param", $params->{$param}), "\n";
}
}
}
# get_query_config_posted_params(url)
# Returns the currently posted parameters from the URL
sub get_query_config_posted_params
{
my ($url) = @_;
foreach my $key (keys %in) {
if ($key =~ /^_cparam-/) {
my $value = $in{$key};
if ($value) {
my $delimiter = ($url =~ /\?/) ? "&" : '?';
$url .= "$delimiter$key=$value"
}
}
}
return $url;
}
# get_config_posted_params(target)
# Returns the referrer URL with all the parameters from the POST request
sub get_config_posted_params
{
my ($target) = @_;
my $param_prefix = "_cparam-";
my $env_referer = $ENV{'HTTP_REFERER'};
my $env_referer_prefixed = ($env_referer =~ /$param_prefix/ ? 1 : 0);
my $params_referer = &read_config_params($env_referer, !$env_referer_prefixed);
my %keys = (%in, %$params_referer);
foreach my $key (keys %keys) {
if ($key =~ /^$param_prefix(.*)/) {
my $k = $1;
my $v = $keys{$key};
if ($v && $target !~ /$k=/) {
my $delimiter = ($target =~ /\?/) ? "&" : '?';
$v = &urlize($v) if ($v =~ /^\//);
$target .= "$delimiter$k=$v"
}
}
}
return $target;
}
1;

View File

@@ -25,6 +25,7 @@ else {
print &ui_form_start("config_save.cgi", "post");
print &ui_hidden("module", $m),"\n";
&print_config_posted_params();
print &ui_table_start(&text('config_header', $module_info{'desc'}),
"width=100%", 2);
&read_file("$config_directory/$m/config", \%newconfig);
@@ -51,5 +52,5 @@ if (!$func) {
print &ui_table_end();
print &ui_form_end([ [ "save", $text{'save'} ] ]);
&ui_print_footer("/$m", $text{'index'});
&ui_print_footer(&get_config_posted_params("/$m/"), $text{'index'});

View File

@@ -56,5 +56,5 @@ if (&foreign_check("webmin")) {
}
&webmin_log("_config_", undef, undef, \%in, $m);
&redirect("/$m/");
&redirect(&get_config_posted_params("/$m/"));

View File

@@ -62,6 +62,7 @@ if (@sections > 1) {
print &ui_form_start("config.cgi");
print &ui_hidden("module", $m),"\n";
print $text{'config_section'},"\n";
&print_config_posted_params();
print &ui_select("section", $in{'section'}, \@sections,
1, 0, 0, 0, "onChange='form.submit()'");
print &ui_submit($text{'config_change'});
@@ -76,6 +77,7 @@ if (@sections > 1) {
print &ui_form_start("config_save.cgi", "post");
print &ui_hidden("module", $m),"\n";
print &ui_hidden("section", $in{'section'}),"\n";
&print_config_posted_params();
if ($s) {
# Find next section
$idx = &indexof($s, @sections);
@@ -122,6 +124,6 @@ if ($m eq "virtual-server") {
&ui_print_footer("/right.cgi", $text{'config_return'});
}
else {
&ui_print_footer("/$m", $text{'index'});
&ui_print_footer(&get_config_posted_params("/$m/"), $text{'index'});
}

View File

@@ -41,13 +41,14 @@ if (&foreign_require($m) &&
}
&webmin_log("_config_", undef, undef, \%in, $m);
my $redirect_url;
if ($in{'save_next'}) {
&redirect("config.cgi?module=$in{'module'}&section=$in{'section_next'}");
$redirect_url = &get_query_config_posted_params("config.cgi?module=$in{'module'}&section=$in{'section_next'}");
}
elsif ($m eq "virtual-server") {
&redirect("/right.cgi");
$redirect_url = "/right.cgi";
}
else {
&redirect("/$m/");
$redirect_url = &get_config_posted_params("/$m/");
}
&redirect($redirect_url);

View File

@@ -1553,7 +1553,7 @@ if ($folder->{'type'} == 1 || $folder->{'type'} == 3) {
&get_maildir_files($folder->{'file'}) :
&get_mhdir_files($folder->{'file'});
if ($folder->{'type'} == 1) {
foreach my $sf (glob("\Q$folder->{'file'}\E/.??*")) {
foreach my $sf (glob("\"$folder->{'file'}\"/.??*")) {
push(@files, &get_maildir_files($sf));
}
}
@@ -3643,7 +3643,7 @@ if (!%hasattach) {
}
else {
$hasattach_file = "$module_config_directory/attach";
if (!glob("\Q$hasattach_file\E.*")) {
if (!glob("\"$hasattach_file\".*")) {
$hasattach_file = "$module_var_directory/attach";
}
}

View File

@@ -1122,7 +1122,7 @@ foreach my $folder (&list_user_folders($user)) {
&unlink_file($ifile);
}
else {
&unlink_file(glob("\Q$ifile\E.{dir,pag,db}"));
&unlink_file(glob("\"$ifile\".{dir,pag,db}"));
}
&unlink_file("$ifile.ids");
}
@@ -1136,7 +1136,7 @@ foreach my $folder (&list_user_folders($user)) {
&unlink_file($ifile);
}
else {
&unlink_file(glob("\Q$ifile\E.{dir,pag,db}"));
&unlink_file(glob("\"$ifile\".{dir,pag,db}"));
}
}
# Remove read file
@@ -1145,7 +1145,7 @@ if (-r $read) {
&unlink_file($read);
}
else {
&unlink_file(glob("\Q$read\E.{dir,pag,db}"));
&unlink_file(glob("\"$read\".{dir,pag,db}"));
}
}
@@ -1280,7 +1280,7 @@ sub user_read_dbm_file
{
my ($user) = @_;
my $rv = "$module_config_directory/$user.read";
if (!glob("\Q$rv\E.*")) {
if (!glob("\"$rv\".*")) {
$rv = "$module_var_directory/$user.read";
}
return $rv;

View File

@@ -606,12 +606,12 @@ foreach my $dat (glob("$config{'minecraft_dir'}/*/level.dat")) {
if (-d "$path/players") {
# Old format
@players = map { s/^.*\///; s/\.dat$//; $_ }
glob("\Q$path\E/players/*");
glob("$path/players/*");
}
if (-d "$path/playerdata" && !@players) {
# New format (UUID based)
@players = map { s/^.*\///; s/\.dat$//; $_ }
glob("\Q$path\E/playerdata/*");
glob("$path/playerdata/*");
@players = map { my $u = $_;
&uuid_to_username($u) || $u } @players;
}

View File

@@ -147,7 +147,7 @@ if (&has_command("ip")) {
$vifc{'edit'} = ($vifc{'name'} !~ /^ppp/);
$vifc{'index'} = scalar(@rv);
push(@rv, \%vifc);
$i = $vn + 1;
$i++;
}
}
}