Fixed crash bug in Template engine when an invalid template is specified.

This commit is contained in:
JT Smith 2002-12-14 17:46:38 +00:00
parent ae01b575c8
commit f05bb29450

View file

@ -13,6 +13,7 @@ package WebGUI::Template;
use HTML::Template; use HTML::Template;
use strict; use strict;
use WebGUI::ErrorHandler; use WebGUI::ErrorHandler;
use WebGUI::International;
use WebGUI::Session; use WebGUI::Session;
use WebGUI::SQL; use WebGUI::SQL;
@ -34,8 +35,9 @@ sub getList {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub process { sub process {
my ($t, $html); my ($t, $test, $html);
$html = $_[0]; $html = $_[0];
eval {
$t = HTML::Template->new( $t = HTML::Template->new(
scalarref=>\$html, scalarref=>\$html,
global_vars=>1, global_vars=>1,
@ -43,16 +45,11 @@ sub process {
die_on_bad_params=>0, die_on_bad_params=>0,
strict=>0 strict=>0
); );
};
unless ($@) {
while (my ($section, $hash) = each %session) { while (my ($section, $hash) = each %session) {
next unless (ref $hash eq 'HASH'); next unless (ref $hash eq 'HASH');
while (my ($key, $value) = each %$hash) { while (my ($key, $value) = each %$hash) {
if (ref $value eq 'ARRAY') {
next;
#$value = '['.join(', ',@$value).']';
} elsif (ref $value eq 'HASH') {
next;
#$value = '{'.join(', ',map {"$_ => $value->{$_}"} keys %$value).'}';
}
unless (lc($key) eq "password" || lc($key) eq "identifier") { unless (lc($key) eq "password" || lc($key) eq "identifier") {
$t->param("session.".$section.".".$key=>$value); $t->param("session.".$section.".".$key=>$value);
} }
@ -61,6 +58,10 @@ sub process {
$t->param(%{$_[1]}); $t->param(%{$_[1]});
$t->param("webgui.version"=>$WebGUI::VERSION); $t->param("webgui.version"=>$WebGUI::VERSION);
return $t->output; return $t->output;
} else {
WebGUI::ErrorHandler::warn("Error in template. ".$@);
return WebGUI::International::get(848).$html;
}
} }