String eval appends "\n;" to the string before evaluating it.
(caller $n)[6], which returns the text of the eval, was giving the
modified string, rather than the original.
In fact, it was returning the actual string buffer that the parser
uses. This commit changes it to create a new mortal SV from that
string buffer, but without the last two characters.
It unfortunately breaks this JAPH:
eval'BEGIN{${\(caller 2)[6]}=~y< !"$()+\-145=ACHMT^acfhinrsty{}>
<nlrhta"o Pe e,\nkrcrJ uthspeia">}say if+chr(1) -int"145"!=${^MATCH}'
if (CxTYPE(cx) == CXt_EVAL) {
/* eval STRING */
if (CxOLD_OP_TYPE(cx) == OP_ENTEREVAL) {
- PUSHs(cx->blk_eval.cur_text);
+ PUSHs(newSVpvn_flags(SvPVX(cx->blk_eval.cur_text),
+ SvCUR(cx->blk_eval.cur_text)-2,
+ SvUTF8(cx->blk_eval.cur_text)|SVs_TEMP));
PUSHs(&PL_sv_no);
}
/* require */
chdir 't' if -d 't';
@INC = '../lib';
require './test.pl';
- plan( tests => 86 );
+ plan( tests => 88 );
}
my @c;
END
"No crash when freed stash is reused for PV with offset hack";
+is eval "(caller 0)[6]", "(caller 0)[6]",
+ 'eval text returned by caller does not include \n;';
+
+# PL_linestr should not be modifiable
+eval '"${;BEGIN{ ${\(caller 2)[6]} = *foo }}"';
+pass "no assertion failure after modifying eval text via caller";
+
$::testing_caller = 1;
do './op/caller.pl' or die $@;