--- loncom/interface/spreadsheet/Spreadsheet.pm 2003/06/23 19:58:18 1.17 +++ loncom/interface/spreadsheet/Spreadsheet.pm 2003/06/25 15:33:49 1.18 @@ -1,5 +1,5 @@ # -# $Id: Spreadsheet.pm,v 1.17 2003/06/23 19:58:18 matthew Exp $ +# $Id: Spreadsheet.pm,v 1.18 2003/06/25 15:33:49 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1202,13 +1202,15 @@ sub html_editable_cell { $value = &HTML::Entities::encode($value) if ($value !~/ /); } return $value if (! $allowed); - # Make the formula safe for outputting - $formula =~ s/\'/\"/g; + # # The formula will be parsed by the browser twice before being - # displayed to the user for editing. - $formula = &HTML::Entities::encode(&HTML::Entities::encode($formula)); - # Escape newlines so they make it into the edit window - $formula =~ s/\n/\\n/gs; + # displayed to the user for editing. + # + # The encoding string "^A-blah" is placed in []'s inside a regexp, so + # we specify the characters we want left alone by putting a '^' in front. + $formula = &HTML::Entities::encode($formula,"^A-z0-9 !#\$%-;=?~"); + # Escape it again - this time the only encodable character is '&' + $formula =~ s/\&/\&/g; # Glue everything together $result .= "".$value."";