--- loncom/interface/loncommon.pm 2014/01/21 14:38:51 1.1171 +++ loncom/interface/loncommon.pm 2014/02/11 14:29:04 1.1173 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1171 2014/01/21 14:38:51 kruse Exp $ +# $Id: loncommon.pm,v 1.1173 2014/02/11 14:29:04 kruse Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3846,7 +3846,7 @@ sub get_previous_attempt { if (($data eq 'award') || ($data eq 'awarddetail')) { my $value = &format_previous_attempt_value($key, $returnhash{$version.':'.$key}); - $prevattempts.=''.&HTML::Entities::encode($value, '"<>&').' '; + $prevattempts.=''.$value.' '; } else { $prevattempts.=' '; } @@ -3854,7 +3854,7 @@ sub get_previous_attempt { if ($key =~ /\./) { my $value = &format_previous_attempt_value($key, $returnhash{$version.':'.$key}); - $prevattempts.=''.&HTML::Entities::encode($value, '"<>&').' '; + $prevattempts.=''.$value.' '; } else { $prevattempts.=' '; } @@ -3865,7 +3865,7 @@ sub get_previous_attempt { next if ($key =~ /\.foilorder$/); my $value = &format_previous_attempt_value($key, $returnhash{$version.':'.$key}); - $prevattempts.=''.&HTML::Entities::encode($value, '"<>&').' '; + $prevattempts.=''.$value.' '; } } $prevattempts.=&end_data_table_row(); @@ -3890,7 +3890,7 @@ sub get_previous_attempt { if ($key =~/$regexp$/ && (defined &$gradesub)) { $value = &$gradesub($value); } - $prevattempts.=''. &HTML::Entities::encode($value, '"<>&').' '; + $prevattempts.=''. $value.' '; } else { $prevattempts.=' '; } @@ -3899,14 +3899,14 @@ sub get_previous_attempt { if ($key =~/$regexp$/ && (defined &$gradesub)) { $value = &$gradesub($value); } - $prevattempts.=''.&HTML::Entities::encode($value, '"<>&').' '; + $prevattempts.=''.$value.' '; } } else { my $value = &format_previous_attempt_value($key,$lasthash{$key}); if ($key =~/$regexp$/ && (defined &$gradesub)) { $value = &$gradesub($value); } - $prevattempts.=''.&HTML::Entities::encode($value, '"<>&').' '; + $prevattempts.=''.$value.' '; } } $prevattempts.= &end_data_table_row().&end_data_table(); @@ -3927,11 +3927,13 @@ sub get_previous_attempt { sub format_previous_attempt_value { my ($key,$value) = @_; if (($key =~ /timestamp/) || ($key=~/duedate/)) { - $value = &Apache::lonlocal::locallocaltime($value); + $value = &Apache::lonlocal::locallocaltime($value); } elsif (ref($value) eq 'ARRAY') { - $value = '('.join(', ', @{ $value }).')'; + $value = &HTML::Entities::encode('('.join(', ', @{ $value }).')','"<>&'); } elsif ($key =~ /answerstring$/) { my %answers = &Apache::lonnet::str2hash($value); + my @answer = %answers; + %answers = map {&HTML::Entities::encode($_, '"<>&')} @answer; my @anskeys = sort(keys(%answers)); if (@anskeys == 1) { my $answer = $answers{$anskeys[0]}; @@ -3954,7 +3956,7 @@ sub format_previous_attempt_value { } } } else { - $value = &unescape($value); + $value = &HTML::Entities::encode(&unescape($value), '"<>&'); } return $value; } @@ -14888,12 +14890,12 @@ sub captcha_display { if ($captcha eq 'original') { $output = &create_captcha(); unless ($output) { - $error = 'captcha'; + $error = 'captcha'; } } elsif ($captcha eq 'recaptcha') { $output = &create_recaptcha($pubkey); unless ($output) { - $error = 'recaptcha'; + $error = 'recaptcha'; } } return ($output,$error); @@ -14973,7 +14975,7 @@ sub create_captcha { $output = ''."\n". &mt('Type in the letters/numbers shown below').' '. '
'. - ''; + 'captcha'; last; } }