[LON-CAPA-cvs] cvs: loncom /auth lonlogin.pm /interface loncommon.pm lonsupportreq.pm

raeburn raeburn at source.lon-capa.org
Mon Nov 25 22:17:10 EST 2013


raeburn		Tue Nov 26 03:17:10 2013 EDT

  Modified files:              
    /loncom/interface	lonsupportreq.pm loncommon.pm 
    /loncom/auth	lonlogin.pm 
  Log:
  - Move &cleanup_html() from lonsupportreq.pm to loncommon.pm to facilitate 
    reuse.
  - Validation. 
  
  
Index: loncom/interface/lonsupportreq.pm
diff -u loncom/interface/lonsupportreq.pm:1.73 loncom/interface/lonsupportreq.pm:1.74
--- loncom/interface/lonsupportreq.pm:1.73	Mon Jul 15 16:13:21 2013
+++ loncom/interface/lonsupportreq.pm	Tue Nov 26 03:17:06 2013
@@ -1,5 +1,5 @@
 #
-# $Id: lonsupportreq.pm,v 1.73 2013/07/15 16:13:21 bisitz Exp $
+# $Id: lonsupportreq.pm,v 1.74 2013/11/26 03:17:06 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -114,7 +114,7 @@
     $formname = 'logproblem';
     my $machine = &Apache::lonnet::absolute_url();
     my $sourceurl = $machine.$origurl;
-    $server = $machine.&cleanup_html($origurl);
+    $server = $machine.&Apache::loncommon::cleanup_html($origurl);
     $server =~ s/\?.*$//;
     my %lt = &Apache::lonlocal::texthash (
                   email => 'The e-mail address you entered',
@@ -676,10 +676,10 @@
         } 
         if (@bad_ccs == 1) {
             if ($bad_ccs[0] ne '') {
-                $badccmsg .= '<br />'.&mt('The following Cc e-mail address is invalid: ').&cleanup_html($bad_ccs[0]);
+                $badccmsg .= '<br />'.&mt('The following Cc e-mail address is invalid: ').&Apache::loncommon::cleanup_html($bad_ccs[0]);
             }
         } elsif (@bad_ccs > 1) {
-            $badccmsg .= '<br />'.&mt('The following Cc e-mail addresses are invalid: '). &cleanup_html(join(', ', at bad_ccs));
+            $badccmsg .= '<br />'.&mt('The following Cc e-mail addresses are invalid: '). &Apache::loncommon::cleanup_html(join(', ', at bad_ccs));
         }
     }
     $env{'form.user'} = "'".$env{'form.uname'}.':'.$env{'form.udom'}."'";
@@ -702,7 +702,7 @@
         if ($env{'form.'.$item} ne '') {
             if ($item eq 'description') {
                 my $descrip = $env{'form.description'};
-                $descrip =  &cleanup_html($descrip);
+                $descrip =  &Apache::loncommon::cleanup_html($descrip);
                 $descrip =~ s|[\n\r\f]|<br />|g;
                 $displaymsg .= 
                     '<span class="LC_helpform_receipt_cat">'.
@@ -710,20 +710,20 @@
             } elsif ($item eq 'sourceurl') {
                 my $showurl = $env{'form.sourceurl'};
                 $showurl =~ s/\?.*$//;
-                $showurl =  &cleanup_html($showurl);
+                $showurl =  &Apache::loncommon::cleanup_html($showurl);
                 $displaymsg .= 
                     '<span class="LC_helpform_receipt_cat">'.
                     "$lt{$item}</span>: $showurl<br />\n";
             } elsif ($item eq 'cc') {
                 if ($okcclist) {
-                    my $showcclist = &cleanup_html($okcclist);
+                    my $showcclist = &Apache::loncommon::cleanup_html($okcclist);
                     $displaymsg .=
                         '<span class="LC_helpform_receipt_cat">'.
                         "$lt{$item}</span>: $showcclist<br />\n";
                 }
             } else {
                 my $showitem = $env{'form.'.$item};
-                $showitem = &cleanup_html($showitem);
+                $showitem = &Apache::loncommon::cleanup_html($showitem);
                 $displaymsg .= 
                     '<span class="LC_helpform_receipt_cat">'.
                     "$lt{$item}</span>: $showitem<br />\n";
@@ -1030,26 +1030,4 @@
     return $codedom;
 }
 
-sub cleanup_html {
-    my ($incoming) = @_;
-    my $outgoing;
-    if ($incoming ne '') {
-        $outgoing = $incoming;
-        $outgoing =~ s/;/;/g;
-        $outgoing =~ s/\#/#/g;
-        $outgoing =~ s/\&/&/g;
-        $outgoing =~ s/</</g;
-        $outgoing =~ s/>/>/g;
-        $outgoing =~ s/\(/&#040/g;
-        $outgoing =~ s/\)/)/g;
-        $outgoing =~ s/"/"/g;
-        $outgoing =~ s/'/'/g;
-        $outgoing =~ s/\$/$/g;
-        $outgoing =~ s{/}{/}g;
-        $outgoing =~ s/=/=/g;
-        $outgoing =~ s/\\/\/g
-    }
-    return $outgoing;
-}
-
 1;
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1160 loncom/interface/loncommon.pm:1.1161
--- loncom/interface/loncommon.pm:1.1160	Tue Nov 26 01:19:15 2013
+++ loncom/interface/loncommon.pm	Tue Nov 26 03:17:07 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1160 2013/11/26 01:19:15 raeburn Exp $
+# $Id: loncommon.pm,v 1.1161 2013/11/26 03:17:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -14910,6 +14910,28 @@
     return $captcha_chk;
 }
 
+sub cleanup_html {
+    my ($incoming) = @_;
+    my $outgoing;
+    if ($incoming ne '') {
+        $outgoing = $incoming;
+        $outgoing =~ s/;/;/g;
+        $outgoing =~ s/\#/#/g;
+        $outgoing =~ s/\&/&/g;
+        $outgoing =~ s/</</g;
+        $outgoing =~ s/>/>/g;
+        $outgoing =~ s/\(/&#040/g;
+        $outgoing =~ s/\)/)/g;
+        $outgoing =~ s/"/"/g;
+        $outgoing =~ s/'/'/g;
+        $outgoing =~ s/\$/$/g;
+        $outgoing =~ s{/}{/}g;
+        $outgoing =~ s/=/=/g;
+        $outgoing =~ s/\\/\/g
+    }
+    return $outgoing;
+}
+
 =pod
 
 =back
Index: loncom/auth/lonlogin.pm
diff -u loncom/auth/lonlogin.pm:1.157 loncom/auth/lonlogin.pm:1.158
--- loncom/auth/lonlogin.pm:1.157	Sun Sep 29 00:49:24 2013
+++ loncom/auth/lonlogin.pm	Tue Nov 26 03:17:09 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Login Screen
 #
-# $Id: lonlogin.pm,v 1.157 2013/09/29 00:49:24 raeburn Exp $
+# $Id: lonlogin.pm,v 1.158 2013/11/26 03:17:09 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -160,11 +160,13 @@
     if ($sessiondata{'username'}) {
         $authusername=$sessiondata{'username'};
     } else {
+        $env{'form.username'} = &Apache::loncommon::cleanup_html($env{'form.username'});
         $authusername=($env{'form.username'}?$env{'form.username'}:'');
     }
     if ($sessiondata{'domain'}) {
         $authdomain=$sessiondata{'domain'};
-    } else { 
+    } else {
+        $env{'form.domain'} = &Apache::loncommon::cleanup_html($env{'form.domain'});
         $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
     }
 




More information about the LON-CAPA-cvs mailing list