Diff for /loncom/xml/scripttag.pm between versions 1.167 and 1.170

version 1.167, 2013/09/26 22:03:36 version 1.170, 2014/07/27 11:39:29
Line 129  sub start_script { Line 129  sub start_script {
       if ($target ne "meta" && $target ne 'tex' && $target ne 'answer') {        if ($target ne "meta" && $target ne 'tex' && $target ne 'answer') {
   $result = $token->[4];    $result = $token->[4];
   $result.=$bodytext;    $result.=$bodytext;
           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);            my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'});
               my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'});            my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
               my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};            my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
               my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};            if ($src ne '') {
               if ($src =~ /\.js$/) {                if ($src !~ m{^(/|https?://)}) {
                   if ($src !~ m{^(/|https?://)}) {                    my $cleanhref = &Apache::londefdef::clean_docs_httpref($src,$url,$cdom,$cnum);
                       my $cleanhref = &Apache::londefdef::clean_docs_httpref($src,$url,$cdom,$cnum);                    if ($cleanhref) {
                       if ($cleanhref) {                        &Apache::lonxml::extlink($cleanhref);
                           &Apache::lonxml::extlink($cleanhref);                    }
                 }
             } elsif (($type eq 'text/javascript') && ($bodytext ne '')) {
                 if ($url =~ m{^\Q/uploaded/$cdom/$cnum/docs/\E}) {
                     if ($bodytext =~ m{\.addMediaSrc\((["'])(?:(?!\1).)+\1\)}) {
                         my $quote = $1;
                         if ($bodytext =~ m{\Q.addMediaSrc($quote\E([^$quote]+)\Q$quote)\E}) {
                             my $fname = $1;
                             my $cleanhref =
                                 &Apache::londefdef::clean_docs_httpref($fname,$url,$cdom,$cnum);
                             if ($cleanhref) {
                                 &Apache::lonxml::extlink($cleanhref);
                             }
                       }                        }
                   }                    }
               } elsif (($src eq '') && ($bodytext ne '')) {                    if ($bodytext =~ m{\.set\w+(Src|Swf)\(["']}i) {
                   if ($url =~ m{^\Q/uploaded/$cdom/$cnum/docs/\E}) {                        my @srcs = split(/\.set/,$bodytext);
                       if ($bodytext =~ m{\.set\w+(Src|Swf)\(["']}i) {                        if (scalar(@srcs) > 1) {
                           my @srcs = split(/\.set/,$bodytext);                            foreach my $item (@srcs) {
                           if (@srcs > 1) {                                if ($item =~ m{^(FlashPlayerSwf|MediaSrc|XMPSrc|ConfigurationSrc|PosterImageSrc)\((['"])(?:(?!\2).)+\2\)}is) {
                               foreach my $item (@srcs) {                                    my $srctype = $1;
                                   if ($item =~ m{^(?:FlashPlayerSwf|MediaSrc|XMPSrc|ConfigurationSrc|PosterImageSrc)\(['"])([^$1]+)$1\)}is) {                                    my $quote = $2;
                                       my $cleanhref = &Apache::londefdef::clean_docs_httpref($2,$url,$cdom,$cnum);                                    my ($fname) = ($item =~ m{^\Q$srctype($quote\E([^$quote]+)\Q$quote)\E}); 
                                       if ($cleanhref) {                                    my $cleanhref =
                                           &Apache::lonxml::extlink($cleanhref);                                        &Apache::londefdef::clean_docs_httpref($fname,$url,$cdom,$cnum);
                                     if ($cleanhref) {
                                         &Apache::lonxml::extlink($cleanhref);
                                         if ($srctype eq 'ConfigurationSrc') {
                                             if ($cleanhref =~ m{^(.+/)configuration_express\.xml$}) {
   #
   # Camtasia 8.1: express_show/spritesheet.png needed, and included in zip archive.
   # Not referenced directly in <main>.html or <main>_player.html files,
   # so call lonxml::extlink() here to include httpref for the uploaded file.
   # (where <main> is name user gave to file/archive).
   #
   
                                                 my $spritesheet = $1.'express_show/spritesheet.png';
                                                 if (&Apache::lonnet::repcopy_userfile($spritesheet) eq 'ok') {
                                                     &Apache::lonxml::extlink($spritesheet);
                                                 }
                                             }
   #
   # Camtasia 8.4: express_show/spritesheet.min.css needed, and included in zip archive.
   # Not referenced directly in <main>.html or <main>_player.html files,
   # so call lonxml::extlink() here to include httpref for the uploaded file.
   # (where <main> is name user gave to file/archive).
   #
                                             my $spritesheet_css = $1.'express_show/spritesheet.min.css';
                                             if (&Apache::lonnet::repcopy_userfile($spritesheet_css) eq 'ok') {
                                                 &Apache::lonxml::extlink($spritesheet_css);
                                             }
                                         } elsif ($srctype eq 'PosterImageSrc') {
                                             if ($fname =~ m{^(.+)_First_Frame\.png$}) {
                                                 my $prefix = $1;
                                                 my ($path) = ($cleanhref =~ m{^(.+/)\Q$fname\E});
   #
   # Camtasia 8.1: <main>_Thumbnails.png needed, and included in zip archive.
   # Not referenced directly in <main>.html or <main>_player.html files,
   # so call lonxml::extlink() here to include httpref for the uploaded file
   # (where <main> is name user gave to file/archive).
   #
                                                 my $thumbnail = $path.$prefix.'_Thumbnails.png';
                                                 if (&Apache::lonnet::repcopy_userfile($thumbnail) eq 'ok') {
                                                     &Apache::lonxml::extlink($thumbnail);
                                                 }
                                             }
                                       }                                        }
                                   }                                    }
                               }                                }
                           }                            }
                       }                        }
                     }
                     if ($bodytext =~ /\(document,\s*(['"])script\1,\s*\[([^\]]+)\]\);/s) {
                         my $scriptslist = $2;
                         my @srcs = split(/\s*,\s*/,$scriptslist);
                         foreach my $src (@srcs) {
                             if ($src =~ /(["'])(?:(?!\1).)+\.js\1/) {
                                 my $quote = $1;
                                 my ($fname) = ($src =~ m/\Q$quote\E([^$quote]+)\Q$quote\E/);
                                 my $cleanhref =
                                     &Apache::londefdef::clean_docs_httpref($fname,$url,$cdom,$cnum);
                                 if ($cleanhref) {
                                     &Apache::lonxml::extlink($cleanhref);
                                 }
                             }
                         }
                   }                    }
               }                }
           }            }

Removed from v.1.167  
changed lines
  Added in v.1.170


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>