[LON-CAPA-cvs] cvs: loncom /homework bridgetask.pm inputtags.pm structuretags.pm /xml lonxml.pm scripttag.pm

albertel lon-capa-cvs-allow@mail.lon-capa.org
Fri, 03 Aug 2007 23:29:58 -0000


albertel		Fri Aug  3 19:29:58 2007 EDT

  Modified files:              
    /loncom/xml	lonxml.pm scripttag.pm 
    /loncom/homework	bridgetask.pm inputtags.pm structuretags.pm 
  Log:
  - more restrictive about what is allowed in id numbers (throws errors on in construct to hopefully not break too many users)
  
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.448 loncom/xml/lonxml.pm:1.449
--- loncom/xml/lonxml.pm:1.448	Mon Jun 11 16:52:40 2007
+++ loncom/xml/lonxml.pm	Fri Aug  3 19:29:54 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.448 2007/06/11 20:52:40 albertel Exp $
+# $Id: lonxml.pm,v 1.449 2007/08/03 23:29:54 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -319,13 +319,14 @@
 	     }
 	 }
      }
- } elsif ($env{'construct.style'} && ($env{'request.state'} eq 'construct')) {
+ } elsif ($env{'construct.style'}
+	  && ($env{'request.state'} eq 'construct')) {
      my $location=&Apache::lonnet::filelocation('',$env{'construct.style'});
      my $styletext=&Apache::lonnet::getfile($location);
-       if ($styletext ne '-1') {
-          %style_for_target = (%style_for_target,
-                          &Apache::style::styleparser($target,$styletext));
-      }
+     if ($styletext ne '-1') {
+	 %style_for_target = (%style_for_target,
+			      &Apache::style::styleparser($target,$styletext));
+     }
  }
 #&printalltags();
  my @pars = ();
@@ -967,8 +968,8 @@
 sub get_id {
     my ($parstack,$safeeval)=@_;
     my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
-    if ($env{'request.state'} eq 'construct' && $id =~ /(\.|_)/) {
-	&error(&mt("IDs are not allowed to contain &quot;<tt>_</tt>&quot; or &quot;<tt>.</tt>&quot;"));
+    if ($env{'request.state'} eq 'construct' && $id =~ /([._]|[^\w\d\s[:punct:]])/) {
+	&error(&mt("ID &quot;[_1]&quot; contains invalid characters, IDs are only allowed to contain letters, numbers, spaces and -",'<tt>'.$id.'</tt>'));
     }
     if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; }
     return $id;
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.141 loncom/xml/scripttag.pm:1.142
--- loncom/xml/scripttag.pm:1.141	Mon Jun 11 16:52:40 2007
+++ loncom/xml/scripttag.pm	Fri Aug  3 19:29:54 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # <script> definiton
 #
-# $Id: scripttag.pm,v 1.141 2007/06/11 20:52:40 albertel Exp $
+# $Id: scripttag.pm,v 1.142 2007/08/03 23:29:54 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -391,7 +391,7 @@
     my $dir=$location;
     $dir=~s:/[^/]*$::;
     #  &Apache::lonxml::debug("directory $dir $location file $file \n<b>END</b>\n");
-    my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
+    my $id= &Apache::lonxml::get_id($parstack,$safeeval);
     if (!$id) { $id=$Apache::lonxml::curdepth; }
     push(@Apache::inputtags::import,$id);
     push(@Apache::inputtags::importlist,$id);
@@ -408,7 +408,7 @@
   } elsif ($target eq 'modified') {
       $result=$token->[4].&Apache::edit::modifiedfield("/import",$parser);
   } elsif ($target eq 'meta') {
-    my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
+    my $id= &Apache::lonxml::get_id($parstack,$safeeval);
     $result.='<import part="'.$Apache::inputtags::part;
     if ($id) {
       $result.='" id="'.$id;
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.235 loncom/homework/bridgetask.pm:1.236
--- loncom/homework/bridgetask.pm:1.235	Wed Aug  1 20:42:35 2007
+++ loncom/homework/bridgetask.pm	Fri Aug  3 19:29:57 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: bridgetask.pm,v 1.235 2007/08/02 00:42:35 albertel Exp $
+# $Id: bridgetask.pm,v 1.236 2007/08/03 23:29:57 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2161,9 +2161,7 @@
 
 sub get_id {
     my ($parstack,$safeeval)=@_;
-    my $id=&Apache::lonxml::get_param('id',$parstack,$safeeval);
-    if (!$id) { $id=$Apache::lonxml::curdepth; }
-    return $id;
+    return &Apache::lonxml::get_id($parstack,$safeeval);
 }
 
 sub start_Setup {
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.227 loncom/homework/inputtags.pm:1.228
--- loncom/homework/inputtags.pm:1.227	Tue Jul 10 16:51:48 2007
+++ loncom/homework/inputtags.pm	Fri Aug  3 19:29:57 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.227 2007/07/10 20:51:48 albertel Exp $
+# $Id: inputtags.pm,v 1.228 2007/08/03 23:29:57 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,7 +31,6 @@
 use Apache::loncommon;
 use Apache::lonlocal;
 use Apache::lonnet;
-use lib '/home/httpd/lib/perl/';
 use LONCAPA;
  
 
@@ -116,8 +115,7 @@
 
 sub start_input {
     my ($parstack,$safeeval)=@_;
-    my $id = &Apache::lonxml::get_param('id',$parstack,$safeeval);
-    if ($id eq '') { $id = $Apache::lonxml::curdepth; }
+    my $id = &Apache::lonxml::get_id($parstack,$safeeval);
     push (@Apache::inputtags::input,$id);
     push (@Apache::inputtags::inputlist,$id);
     return $id;
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.385 loncom/homework/structuretags.pm:1.386
--- loncom/homework/structuretags.pm:1.385	Tue Jul 24 14:03:54 2007
+++ loncom/homework/structuretags.pm	Fri Aug  3 19:29:57 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.385 2007/07/24 18:03:54 albertel Exp $
+# $Id: structuretags.pm,v 1.386 2007/08/03 23:29:57 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -319,7 +319,7 @@
     $result.= ' />'.$show_all_foils_text.'</label></span>'.
 	&Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems').
 	'<hr />';
-    $result.=&mt('Apply style file').'
+    $result.=&mt('Apply style file: ').'
 <input type="text" name="style_file" value="'.&HTML::Entities::encode($env{'construct.style'},'"<>&').'" />
  <a href="javascript:openbrowser(\'lonhomework\',\'style_file\',\'sty\')">'.&mt('Select').'</a>
 <input type="submit" name="clear_style_file" value="'.&mt('Clear').'" />
@@ -1375,8 +1375,7 @@
 	                                     # duedates.
     }
     my $result='';
-    my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
-    if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; }
+    my $id= &Apache::lonxml::get_id($parstack,$safeeval);
     $Apache::inputtags::part=$id;
     push(@Apache::inputtags::partlist,$id);
     @Apache::inputtags::response=();