[LON-CAPA-cvs] cvs: rat / lonratedt.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 16 Jan 2007 21:10:56 -0000


albertel		Tue Jan 16 16:10:56 2007 EDT

  Modified files:              
    /rat	lonratedt.pm 
  Log:
  - Simple Rat wasn't handling around urls with , correctly (BUG#5147)
  
  
Index: rat/lonratedt.pm
diff -u rat/lonratedt.pm:1.86 rat/lonratedt.pm:1.87
--- rat/lonratedt.pm:1.86	Wed Dec 20 17:42:48 2006
+++ rat/lonratedt.pm	Tue Jan 16 16:10:55 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Edit Handler for RAT Maps
 #
-# $Id: lonratedt.pm,v 1.86 2006/12/20 22:42:48 albertel Exp $
+# $Id: lonratedt.pm,v 1.87 2007/01/16 21:10:55 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -173,7 +173,7 @@
 use LONCAPA::map();
 use File::Copy;
 use LONCAPA;
-
+use HTML::Entities();
 
 # --------------------------------------------------------- Build up RAT screen
 sub ratedt {
@@ -602,10 +602,12 @@
        my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$_]);
        unless ($name) {  $name=(split(/\//,$url))[-1]; }
        unless ($name) { $name='EMPTY'; }
+       $name = &LONCAPA::map::qtescape($name);
+       $url  = &LONCAPA::map::qtescape($url);
        $targetdetail.='&'.&escape($name).'='.
 	                  &escape($url);
        $idx++;
-       $name=~s/\:/\:/g;
+       $name = &HTML::Entities::encode($name,'\'"<>&');
        '<option value="'.$idx.'">'.$name.'</option>';
    } @LONCAPA::map::order);
 
@@ -642,8 +644,6 @@
    function openview(entry) {
        var url=unescape((entry.split('='))[1]);
        var parts=new Array;
-       parts=url.split('&colon;');
-       url=parts.join(':');
        if (url) { open(url,'cat'); }
    }
 
@@ -662,12 +662,6 @@
        var entry=(document.forms.simpleedit.targetdetail.value.split('&'))
                 [selidx];
        var oldname=unescape((entry.split('='))[0]);
-       var nameparts=oldname.split('&colon;');
-       oldname=unescape(nameparts.join(':'));
-       nameparts=oldname.split('&#34;');
-       oldname=unescape(nameparts.join('"'));
-       nameparts=oldname.split('&#39;');
-       oldname=unescape(nameparts.join("'"));
        newtitle=prompt('$lt{'nt'}',oldname);
        if (newtitle) {
            document.forms.simpleedit.renameres.value=1;
@@ -800,11 +794,11 @@
             $idx++;
 	    my ($title,$url,$cond)=split(/\:/,$_);
 	    if ($cond eq 'cond') { next; }
-            $title=~s/\&colon\;/\:/g;
-            $url=~s/\&colon\;/\:/g;
+            $title= &LONCAPA::map::qtescape($title);
+            $url  = &LONCAPA::map::qtescape($url);
             unless ($title) { $title=(split(/\//,$url))[-1] };
             unless ($title) { $title='<i>'.&mt('Empty').'</i>'; }
-            my $resurl = &LONCAPA::map::qtescape($url);
+            my $resurl = $url;
             my $resfilepath = $Apache::lonnet::perlvar{'lonDocRoot'}.$resurl;
             my $filename; 
             if ($resurl =~ m#/([^/]+)$#) {
@@ -815,7 +809,7 @@
             my $bgcol = $idx%2; 
             $r->print('<tr bgcolor='.$backgroundColors[$bgcol].'><td>'.
                       '<img src="'.&Apache::loncommon::icon($resfilepath).
-                      '" /></td><td>'.&LONCAPA::map::qtescape($title).
+                      '" /></td><td>'.&HTML::Entities::encode(&LONCAPA::map::qtescape($title)).
                       '</td><td>'.$filename.'</td><td>');
             if ($url) {
 		$r->print('<a href="'.$resurl.'">'.&mt('Resource space').'</a>');