--- loncom/interface/loncommon.pm 2022/10/27 20:30:11 1.1393 +++ loncom/interface/loncommon.pm 2022/10/29 17:44:05 1.1394 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1393 2022/10/27 20:30:11 raeburn Exp $ +# $Id: loncommon.pm,v 1.1394 2022/10/29 17:44:05 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -18673,15 +18673,23 @@ sub validate_folderpath { my ($supplementalflag,$allowed,$coursenum,$coursedom) = @_; if ($env{'form.folderpath'} ne '') { my @items = split(/\&/,$env{'form.folderpath'}); - my ($badpath,$got_supp,$supppath,%supphidden,%suppids); + my ($badpath,$changed,$got_supp,$supppath,%supphidden,%suppids); for (my $i=0; $i<@items; $i++) { my $odd = $i%2; if (($odd) && (!$supplementalflag) && ($items[$i] !~ /^[^:]*:(|\d+):(|1):(|1):(|1):(|1)$/)) { $badpath = 1; - } elsif ($odd && $supplementalflag && $allowed) { - my $suffix; + } elsif ($odd && $supplementalflag) { my $idx = $i-1; - if (($items[$i] !~ /^[^:]*::(|1):::$/) && ($items[$idx] ne 'supplemental')) { + if ($items[$i] =~ /^([^:]*)::(|1):::$/) { + my $esc_name = $1; + if ((!$allowed) || ($items[$idx] eq 'supplemental')) { + $supppath .= '&'.$esc_name; + $changed = 1; + } else { + $supppath .= '&'.$items[$i]; + } + } elsif (($allowed) && ($items[$idx] ne 'supplemental')) { + $changed = 1; my $is_hidden; unless ($got_supp) { my ($supplemental) = &Apache::lonnet::get_supplemental($coursenum,$coursedom); @@ -18701,19 +18709,20 @@ sub validate_folderpath { $is_hidden = 1; } } - $suffix = '::'.$is_hidden.':::'; + $supppath .= '&'.$items[$i].'::'.$is_hidden.':::'; + } else { + $supppath .= '&'.$items[$i]; } - $supppath .= '&'.$items[$i].$suffix; } elsif ((!$odd) && ($items[$i] !~ /^(default|supplemental)(|_\d+)$/)) { $badpath = 1; - } elsif (!$odd && $supplementalflag && $allowed) { + } elsif ($supplementalflag) { $supppath .= '&'.$items[$i]; } last if ($badpath); } if ($badpath) { delete($env{'form.folderpath'}); - } elsif ($supplementalflag && $allowed) { + } elsif ($changed && $supplementalflag) { $supppath =~ s/^\&//; $env{'form.folderpath'} = $supppath; }