From 5413c174cba222af9e0303a1fe3cd3cdb0759edc Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Tue, 22 Aug 2023 18:10:38 -0500 Subject: [PATCH] Remove html formatting in a warn statement. Here is a minimal working example to demonstrate the change: ```perl DOCUMENT(); loadMacros('PGstandard.pl'); BEGIN_TEXT \{ foo() \} END_TEXT ENDDOCUMENT(); ``` With the develop branch the warning messages for this problem will be: * `ERROR in old_safe_ev, PGbasicmacros.pl:
`
* `## There is an error occuring inside evaluation brackets \{ ...code... \}`
* `## somewhere in an EV2 or EV3 or BEGIN_TEXT block.`
* `## Code evaluated:`
* `## foo()`
* `##Undefined subroutine &main::foo called at line 1 of (eval 7649).`
* `##

` * `at line 2080 of [PG]/macros/core/PGbasicmacros.pl.` Since these warnings are now xml escaped by webwork2 the html formatting no longer works. With this branch they will be: * `There is an error occuring inside evaluation brackets \{ ...code... \} somewhere in an EV2, EV3, or BEGIN_TEXT block.` * `Code evaluated:` * `foo()` * `Errors:` * `Undefined subroutine &main::foo called at line 1 of (eval 7742).` I don't think that the "ERROR in old_safe_ev, PGbasicmacros.pl" part is useful for problem authors, so that was dropped. Also remove the `;` from the end of the eval, and the comment about it. Testing shows that comment is false. --- macros/core/PGbasicmacros.pl | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/macros/core/PGbasicmacros.pl b/macros/core/PGbasicmacros.pl index bde1d92002..9c9f0cc2d4 100644 --- a/macros/core/PGbasicmacros.pl +++ b/macros/core/PGbasicmacros.pl @@ -2072,23 +2072,18 @@ sub safe_ev { sub old_safe_ev { my $in = shift; - my ($out, $PG_eval_errors, $PG_full_error_report) = PG_restricted_eval("$in;"); - # the addition of the ; seems to provide better error reporting + my ($out, $PG_eval_errors, $PG_full_error_report) = PG_restricted_eval($in); if ($PG_eval_errors) { my @errorLines = split("\n", $PG_eval_errors); -#$out = "
$PAR % ERROR in $0:old_safe_ev, PGbasicmacros.pl: $PAR % There is an error occuring inside evaluation brackets \\{ ...code... \\} $BR % somewhere in an EV2 or EV3 or BEGIN_TEXT block. $BR % Code evaluated:$BR $in $BR % $BR % $errorLines[0]\n % $errorLines[1]$BR % $BR % $BR 
"; - warn " ERROR in old_safe_ev, PGbasicmacros.pl:
-		## There is an error occuring inside evaluation brackets \\{ ...code... \\}
-		## somewhere in an EV2 or EV3 or BEGIN_TEXT block.
-		## Code evaluated:
-		## $in
-		##" . join("\n     ", @errorLines) . "
-		##
$BR - "; + warn "There is an error occuring inside evaluation brackets \\{ ...code... \\} " + . "somewhere in an EV2, EV3, or BEGIN_TEXT block.\n" + . "Code evaluated:\n$in\n" + . "Errors:\n" + . join("\n", @errorLines) . "\n"; $out = "$PAR $BBOLD $in $EBOLD $PAR"; } - ($out, $PG_eval_errors, $PG_full_error_report); + return ($out, $PG_eval_errors, $PG_full_error_report); } sub FEQ { # Format EQuations