From: Mike G. <ga...@de...> - 2005-05-19 16:19:02
|
Log Message: ----------- Use base64 to save answers -- this ensures that symbols in the answer won't cause trouble. I have added a string to the beginning of the encoded passage: base64_encoded:AFDWERADADFRET -- Mike Modified Files: -------------- webwork-modperl/lib/WeBWorK: Utils.pm Revision Data ------------- Index: Utils.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/Utils.pm,v retrieving revision 1.61 retrieving revision 1.62 diff -Llib/WeBWorK/Utils.pm -Llib/WeBWorK/Utils.pm -u -r1.61 -r1.62 --- lib/WeBWorK/Utils.pm +++ lib/WeBWorK/Utils.pm @@ -31,8 +31,6 @@ use Date::Format; use Time::Zone; use MIME::Base64; -#use Date::Manip; -#use DateTime::Format::DateManip; use Errno; use File::Path qw(rmtree); use Carp; @@ -650,11 +648,15 @@ $result .= defined $ref ? $ref : '<font color="red">undef</font>'; } } - +use constant BASE64_ENCODED => 'base64_encoded:'; sub decodeAnswers($) { my $string = shift; - $string = decode_base64($string); return unless defined $string and $string; + if ($string =~/^BASE64_ENCODED/) { + $string =~ s/^BASE64_ENCODED//; + $string = decode_base64($string); + } + my @array = split m/##/, $string; $array[$_] =~ s/\\#\\/#/g foreach 0 .. $#array; push @array, "" if @array%2; @@ -681,7 +683,9 @@ $string .= "$name##$value##"; # this is also not my fault } $string =~ s/##$//; # remove last pair of hashs - $string = encode_base64($string); + + $string = BASE64_ENCODED.encode_base64($string); + return $string; } |