/usr/share/piwi/Functions/parser.pl is in piwi 0.8+20041206-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | sub ParseComponent($)
{
my $Component = shift;
my $ComponentDir = 'Templates/';
my $Path = $ComponentDir.'/'.$Component;
$Path =~ s/\/+/\//g;
local *Component;
undef $!;
open( Component, $Path );
if ( $! and ( $! !~ m/Inappropriate ioctl for device/i ) )
{
debug( "Missing component <b>$Path</b> : $!" );
return 0;
}
else
{
my $Template = '';
while( my $Line = <Component> ) {$Template .= $Line;}
close( Component );
$Template =~ s/\r//mg;
$Template =~ s/<\?\n+/<?/mg;
$Template =~ s/\n+\?>/?>/mg;
while( $Template )
{
# Special case : <??IDMEF Path??>
$Template =~ s/<\?\?(.*?)\?\?>/get( $1 ) || ' '/meg;
my ( $BeforeCode, $tmp ) = split( /<\?/m, $Template, 2 );
$Template = $tmp || '';
# Something before a tag, print it :
if ( $BeforeCode ) {print $BeforeCode;};
my ( $Code, $AfterCode ) = split( /\?>/m, $Template, 2 );
$Template = $AfterCode || '';
if ( $Code ) { exec_code( $Code ); };
}
}
}
sub exec_code($)
{
my $Code = shift;
eval( $Code );
if ($@)
{
$Code =~ s/</</g;
$Code =~ s/>/>/g;
my ( $LineNb ) = ( $@ =~ m/line (\d+)/ );
if ( $LineNb )
{
$LineNb -= 3;
my @Code = split( /\n/, $Code );
$Code = join( "\n", @Code[ 0..( $LineNb - 3 ) ] )."\n";
$Code .= '<font color=red>';
$Code .= join( "\n", @Code[ ( $LineNb - 2 )..( $LineNb + 2 ) ] );
$Code .= '</font>';
$Code .= "\n".join( "\n", @Code[ ( $LineNb + 3 )..$#Code ] );
}
debug( "Error in Perl code :($@)<br>\n$Code" );
}
}
1;
|