--- rat/map.pm 2006/12/05 02:55:55 1.3 +++ rat/map.pm 2007/08/02 01:47:42 1.8 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # routines for modyfing .sequence and .page files # -# $Id: map.pm,v 1.3 2006/12/05 02:55:55 albertel Exp $ +# $Id: map.pm,v 1.8 2007/08/02 01:47:42 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -29,6 +29,7 @@ package LONCAPA::map; use HTML::TokeParser; +use HTML::Entities(); use Apache::lonnet; use Apache::lonlocal; use File::Copy; @@ -244,14 +245,21 @@ sub attemptread { # ------------------------------------- Revive zombie idx or get unused number sub getresidx { - my $url=shift; + my ($url,$residx)= @_; my $max=1+($#resources>$#zombies?$#resources:$#zombies); unless ($url) { return $max; } for (my $i=0; $i<=$#zombies; $i++) { my ($title,$src,$ext,$type)=split(/\:/,$zombies[$i]); if ($src eq $url) { - undef($zombies[$i]); - return $i; + if ($residx) { + if ($i == $residx) { + undef($zombies[$i]); + return $i; + } + } else { + undef($zombies[$i]); + return $i; + } } } return $max; @@ -276,11 +284,11 @@ sub pastetarget { my @insertorder=(); foreach (@which) { if (defined($_)) { - my ($name,$url)=split(/\=/,$_); + my ($name,$url,$residx)=split(/\=/,$_); $name=&unescape($name); $url=&unescape($url); if ($url) { - my $idx=&getresidx($url); + my $idx=&getresidx($url,$residx); $insertorder[$#insertorder+1]=$idx; my $ext='false'; if ($url=~/^http\:\/\//) { $ext='true'; } @@ -439,7 +447,7 @@ sub qtescape { $str=~s/\&\#58\;/\:/g; $str=~s/\&\#39\;/\'/g; $str=~s/\&\#44\;/\,/g; - $str=~s/\"/\&\#34\;/g; + $str=~s/\&\#34\;/\"/g; return $str; } @@ -476,7 +484,7 @@ sub loadmap { if ($instr eq -2) { $errtext.='Map not loaded: An error occured while trying to load the map.'; } elsif ($instr eq '-1') { - $errtext.=&mt('Map not loaded: The file [_1] does not exist.',$fn); + # Map doesn't exist } elsif ($instr) { my $parser = HTML::TokeParser->new(\$instr); my $token; @@ -625,6 +633,8 @@ sub savemap { # --------------------------------------------------------------- Logical input if (($comp[$#comp] eq 'res') || ($comp[$#comp] eq 'zombie')) { $comp[0]=qtescape($comp[0]); + $comp[0] = &HTML::Entities::encode($comp[0],'&<>"'); + $comp[1]=qtescape($comp[1]); if ($comp[2] eq 'true') { if ($comp[1]!~/^http\:\/\//) {