version 1.166, 2012/08/07 14:50:17
|
version 1.167, 2013/09/26 22:03:36
|
Line 31 package Apache::scripttag;
|
Line 31 package Apache::scripttag;
|
use strict; |
use strict; |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
use Apache::lonxml(); |
|
use Apache::londefdef(); |
use Apache::style(); |
use Apache::style(); |
|
|
#Globals |
#Globals |
Line 129 sub start_script {
|
Line 131 sub start_script {
|
$result.=$bodytext; |
$result.=$bodytext; |
if ($type eq "text/javascript") { |
if ($type eq "text/javascript") { |
my $src=&Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1); |
my $src=&Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1); |
if (($src =~ /\.js$/) && ($src !~ m{^(/|https?://)})) { |
my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'}); |
my ($path,$scriptname) = ($src =~ m{^(.+)/([^/]*)$}); |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $docuri = |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$Apache::lonnet::env{'request.noversionuri'}; |
if ($src =~ /\.js$/) { |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
if ($src !~ m{^(/|https?://)}) { |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cleanhref = &Apache::londefdef::clean_docs_httpref($src,$url,$cdom,$cnum); |
if ($docuri =~ m{^(\Q/uploaded/$cdom/$cnum\E)/(docs/.*/)[^/]+$}) { |
if ($cleanhref) { |
my $prefix = $1; |
&Apache::lonxml::extlink($cleanhref); |
my $relpath = $2; |
|
my $cleanrelpath; |
|
foreach my $dir (split(/\//,$relpath.$path)) { |
|
next if ($dir eq '.'); |
|
if ($dir eq '..') { |
|
$cleanrelpath =~ s{([^/]+/)$}{}; |
|
} else { |
|
$cleanrelpath .= $dir.'/'; |
|
} |
|
} |
|
$cleanrelpath =~ s{/$}{}; |
|
if ($cleanrelpath ne '') { |
|
$src = $prefix.'/'.$cleanrelpath.'/'.$scriptname; |
|
} else { |
|
$src = $prefix.'/'.$scriptname; |
|
} |
} |
if ($src ne '') { |
} |
&Apache::lonxml::extlink($src); |
} elsif (($src eq '') && ($bodytext ne '')) { |
|
if ($url =~ m{^\Q/uploaded/$cdom/$cnum/docs/\E}) { |
|
if ($bodytext =~ m{\.set\w+(Src|Swf)\(["']}i) { |
|
my @srcs = split(/\.set/,$bodytext); |
|
if (@srcs > 1) { |
|
foreach my $item (@srcs) { |
|
if ($item =~ m{^(?:FlashPlayerSwf|MediaSrc|XMPSrc|ConfigurationSrc|PosterImageSrc)\(['"])([^$1]+)$1\)}is) { |
|
my $cleanhref = &Apache::londefdef::clean_docs_httpref($2,$url,$cdom,$cnum); |
|
if ($cleanhref) { |
|
&Apache::lonxml::extlink($cleanhref); |
|
} |
|
} |
|
} |
|
} |
} |
} |
} |
} |
} |
} |