This will allow any editor (means anyone for unprotected Wikis) to insert Perl code into Wiki sites. You simply place <perl>-tags into your page and write a nameless sub inside them. UseMod then replaces the tag bit with the return value of the code reference.
I.e.:
<perl>
sub {
return "\n= Hello world! =\n";
}
</perl>
will give a "Hello world!"-heading 1 as the output is parsed in the usual way (almost) by UseMod. This is highly dangerous!!! Unless the wiki is protected and public to a very limited set of persons of high trust I would not recommend applying this patch.
After line 1574:
my ($pageText) = @_;
insert:
my ($PerlCode?, $ReturnValue?);
and after line 1590:
$pageText = &RemoveFS?($pageText);
insert:
# To be able to EMBED PERL CODE...
if ( $AllowEval? ) {
while ( $pageText =~ m!<perl>((.|\n)*?)</perl>!mig ) {
$PerlCode? = eval( $1 );
$ReturnValue? = &{$PerlCode?}() if ( ref $PerlCode? );
$pageText =~
s!<perl>((.|\n)*?)</perl>!&StoreRaw(&ParseParagraph?($ReturnValue?))!mie;
}
}
# MIGHT BE A SECURITY HAZARD!!!
You have to change
use strict;
into
use strict 'vars';
and you will like to insert $AllowEval? into the list of variables declared at the top of UseMod.
After that, you can put $AllowEval? into your config file and set it to 1. Happy coding ;) --Udo Güngerich, 2005-08-22