[LON-CAPA-cvs] cvs: loncom /interface londocs.pm rat map.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 26 Jan 2007 23:37:53 -0000


albertel		Fri Jan 26 18:37:53 2007 EDT

  Modified files:              
    /rat	map.pm 
    /loncom/interface	londocs.pm 
  Log:
  - removing some &colon manipulations to use the qt(un)escape ruotines
  - switching qtesacpe to do no html escaping, the title as returned from it is the exact text to display (as most places expect)
  
  
Index: rat/map.pm
diff -u rat/map.pm:1.5 rat/map.pm:1.6
--- rat/map.pm:1.5	Tue Jan 16 16:18:08 2007
+++ rat/map.pm	Fri Jan 26 18:37:51 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # routines for modyfing .sequence and .page files
 #
-# $Id: map.pm,v 1.5 2007/01/16 21:18:08 albertel Exp $
+# $Id: map.pm,v 1.6 2007/01/26 23:37:51 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -440,7 +440,7 @@
     $str=~s/\&\#58\;/\:/g;
     $str=~s/\&\#39\;/\'/g;
     $str=~s/\&\#44\;/\,/g;
-    $str=~s/\"/\&\#34\;/g;
+    $str=~s/\&\#34\;/\"/g;
     return $str;
 }
 
@@ -626,6 +626,8 @@
 # --------------------------------------------------------------- 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\:\/\//) {
@@ -644,7 +646,7 @@
 			$outstr.=' type="'.$comp[3].'"';
 		    }
 		    if ($comp[0] ne '') {
-			$outstr.=' title="'.&HTML::Entities::encode($comp[0]).'"';
+			$outstr.=' title="'.$comp[0].'"';
 		    }
 		    $outstr.=" />\n";
 		} elsif ($comp[$#comp] eq 'cond') {
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.269 loncom/interface/londocs.pm:1.270
--- loncom/interface/londocs.pm:1.269	Tue Jan  9 14:10:46 2007
+++ loncom/interface/londocs.pm	Fri Jan 26 18:37:53 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.269 2007/01/09 19:10:46 albertel Exp $
+# $Id: londocs.pm,v 1.270 2007/01/26 23:37:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -235,7 +235,6 @@
 	    my ($ext)=($_=~/\.(\w+)$/);
 	    my $title=$hash{'title_'.$hash{
 		'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
-	    $title=~s/&colon;/:/g;
 	    $r->print('<td>'.($title?$title:'&nbsp;').'</td>');
 	    if (!$title) {
 		$title=$_;
@@ -937,8 +936,8 @@
 	    $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
 	    my $ext = 'false';
 	    if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
-	    $url =~ s/:/\&colon;/g;
-	    $name =~ s/:/\&colon;/g;
+	    $url  =~ &LONCAPA::map::qtunescape($url);
+	    $name =~ &LONCAPA::map::qtunescape($name);
 	    $LONCAPA::map::resources[$idx] = 
 		join ':', ($name, $url, $ext, 'normal', 'res');
 	}
@@ -1316,12 +1315,10 @@
 			 &Apache::lonnet::getfile($url));
 		    $url=$newurl;
 		}
-		$title=~s/\</\&lt\;/g;
-		$title=~s/\>/\&gt\;/g;
-		$title=~s/\:/\&colon;/g;
+		$title = &LONCAPA::map::qtunescape($title);
 		my $ext='false';
 		if ($url=~/^http\:\/\//) { $ext='true'; }
-		$url=~s/\:/\&colon;/g;
+		$url   = &LONCAPA::map::qtunescape($url);
 # Now insert the URL at the bottom
                 my $newidx=&LONCAPA::map::getresidx($url);
 		$LONCAPA::map::resources[$newidx]=
@@ -1373,19 +1370,14 @@
                     my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
                     my ($rtitle,@rrest)=split(/\:/,
                        $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]);
-                    my $comment=
-                     &HTML::Entities::decode($env{'form.title'});
-                    $comment=~s/\</\&lt\;/g;
-                    $comment=~s/\>/\&gt\;/g;
-                    $comment=~s/\:/\&colon;/g;
+                    my $comment=$env{'form.title'};
+                    $comment = &LONCAPA::map::qtunescape($comment);
 		    if ($comment=~/\S/) {
 			$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
 			    $comment.':'.join(':',@rrest);
 		    }
 # Devalidate title cache
-                    my $renamed_url=$rrest[0];
-# Has the &colon;-escaping
-                    $renamed_url=~s/\&colon\;/\:/g;
+                    my $renamed_url=&LONCAPA::map::qtescape($rrest[0]);
 		    &Apache::lonnet::devalidate_title_cache($renamed_url);
                 }
 # Store the changed version
@@ -1456,7 +1448,7 @@
         foreach (@LONCAPA::map::order) {
            my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$_]);
 	   $name=&LONCAPA::map::qtescape($name);
-	   $url=&LONCAPA::map::qtescape($url);
+	   $url =&LONCAPA::map::qtescape($url);
            unless ($name) {  $name=(split(/\//,$url))[-1]; }
            unless ($name) { $idx++; next; }
            $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum));
@@ -1539,11 +1531,9 @@
 						$codebase);
         my $ext='false';
         if ($url=~/^http\:\/\//) { $ext='true'; }
-        $url=~s/\:/\&colon;/g;
+	$url     = &LONCAPA::map::qtunescape($url);
         my $comment=$env{'form.comment'};
-        $comment=~s/\</\&lt\;/g;
-        $comment=~s/\>/\&gt\;/g;
-        $comment=~s/\:/\&colon;/g;
+	$comment = &LONCAPA::map::qtunescape($comment);
         if ($folder=~/^supplemental/) {
               $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
                   $env{'user.domain'}.'___&&&___'.$comment;
@@ -1641,9 +1631,7 @@
 
 sub entryline {
     my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
-    $title=~s/\&colon\;/\:/g;
-    $title=&HTML::Entities::encode(&HTML::Entities::decode(
-     &unescape($title)),'"<>&\'');
+    $title=&HTML::Entities::encode($title,'"<>&\'');
     my $renametitle=$title;
     my $foldertitle=$title;
     my $pagetitle=$title;