--- loncom/lonencurl.pm 2011/10/01 03:18:57 1.5 +++ loncom/lonencurl.pm 2020/03/04 16:33:35 1.7 @@ -2,7 +2,7 @@ # The LearningOnline Network # URL translation for encrypted filenames # -# $Id: lonencurl.pm,v 1.5 2011/10/01 03:18:57 raeburn Exp $ +# $Id: lonencurl.pm,v 1.7 2020/03/04 16:33:35 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -76,11 +76,35 @@ sub handler { } } } + my $anchor; if ($redirect eq '') { $redirect=&Apache::lonenc::unencrypted($r->uri); + if ($redirect =~ m{^/adm/wrapper/ext/[^\#]+(\#.+)$}) { + $anchor = $1; + $redirect =~ s/\#.+$//; + } elsif (($redirect =~ m{^https?://}) && ($r->args)) { + my $symb; + foreach my $item (split(/\&/,$r->args)) { + my ($key,$value) = split(/=/,$item); + if ($key eq 'symb') { + $symb = &Apache::lonenc::unencrypted($value); + last; + } + } + if ($symb) { + my ($map,$id,$res) = &Apache::lonnet::decode_symb($symb); + if (($map =~ /\.page$/) && ($res =~ m{^ext/})) { + if ($res =~ /(\#[^#]+)$/) { + $anchor = $1; + } + $r->headers_out->set(Location => $redirect.$anchor); + return REDIRECT; + } + } + } } if ($r->args) { $redirect.='?'.$r->args; } - $r->internal_redirect($redirect); + $r->internal_redirect($redirect.$anchor); return OK; } return FORBIDDEN;