--- loncom/xml/londefdef.pm 2013/09/26 22:03:36 1.447 +++ loncom/xml/londefdef.pm 2013/09/30 13:44:16 1.448 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.447 2013/09/26 22:03:36 raeburn Exp $ +# $Id: londefdef.pm,v 1.448 2013/09/30 13:44:16 raeburn Exp $ # # # Copyright Michigan State University Board of Trustees @@ -1732,7 +1732,7 @@ sub start_a { my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; if ($linkurl =~ m{^([^/]|/uploaded/$cdom/$cnum/docs/)}) { - my $cleanhref = &Apache::londefdef::clean_docs_httpref($linkurl,$url,$cdom,$cnum); + my $cleanhref = &clean_docs_httpref($linkurl,$url,$cdom,$cnum); if ($cleanhref) { &Apache::lonxml::extlink($cleanhref); } @@ -3619,20 +3619,20 @@ sub start_iframe { } else { $currentstring = $token->[4]; } - if (($url !~ m{^https?://}) && ($env{'request.course.id'})) { - my $docuri = &Apache::lonnet::hreflocation('',$env{'request.filename'}); - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - if ($url =~ m{^([^/]|/uploaded/)}) { - my $cleanhref = &Apache::londefdef::clean_docs_httpref($url,$docuri,$cdom,$cnum); - if ($cleanhref) { - &Apache::lonxml::extlink($cleanhref); - } - } elsif (($url =~ m{/res/$LONCAPA::domain_re/}) && ($docuri =~ m{^\Q/uploaded/$cdom/$cnum/docs/\E})) { - if (!&Apache::lonnet::allowed('bre',$url)) { - if (&Apache::lonnet::is_on_map($url)) { - &Apache::lonxml::extlink($url); - } + } + if (($url !~ m{^https?://}) && ($env{'request.course.id'})) { + my $docuri = &Apache::lonnet::hreflocation('',$env{'request.filename'}); + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + if ($url =~ m{^([^/]|/uploaded/)}) { + my $cleanhref = &clean_docs_httpref($url,$docuri,$cdom,$cnum); + if ($cleanhref) { + &Apache::lonxml::extlink($cleanhref); + } + } elsif (($url =~ m{/res/$LONCAPA::domain_re/}) && ($docuri =~ m{^\Q/uploaded/$cdom/$cnum/docs/\E})) { + if (!&Apache::lonnet::allowed('bre',$url)) { + if (&Apache::lonnet::is_on_map($url)) { + &Apache::lonxml::extlink($url); } } } @@ -4612,8 +4612,17 @@ sub clean_docs_httpref { return $cleanhref; } } else { - (my $path,$fname) = ($href =~ m{^(.+)/([^/]*)$}); - $hrefpath = $relpath.$path; + if ($href =~ m{/}) { + (my $path,$fname) = ($href =~ m{^(.*)/([^/]*)$}); + $hrefpath = $relpath.$path; + if ($path eq '') { + $hrefpath =~ s{/$}{}; + } + } else { + $fname = $href; + $hrefpath = $relpath; + $hrefpath =~ s{/$}{}; + } } if ($fname ne '') { my $cleanrelpath; @@ -4625,11 +4634,10 @@ sub clean_docs_httpref { $cleanrelpath .= $dir.'/'; } } - $cleanrelpath =~ s{/$}{}; if ($cleanrelpath ne '') { - $cleanhref = $prefix.'/'.$cleanrelpath.'/'.$fname; + $cleanhref = $prefix.$cleanrelpath.$fname; } else { - $cleanhref = $prefix.'/'.$fname; + $cleanhref = $prefix.$fname; } } }