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,33 +35,33 @@ sub getList {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub process { sub process {
my ($t, $html); my ($t, $test, $html);
$html = $_[0]; $html = $_[0];
$t = HTML::Template->new( eval {
scalarref=>\$html, $t = HTML::Template->new(
global_vars=>1, scalarref=>\$html,
loop_context_vars=>1, global_vars=>1,
die_on_bad_params=>0, loop_context_vars=>1,
strict=>0 die_on_bad_params=>0,
); strict=>0
while (my ($section, $hash) = each %session) { );
next unless (ref $hash eq 'HASH'); };
while (my ($key, $value) = each %$hash) { unless ($@) {
if (ref $value eq 'ARRAY') { while (my ($section, $hash) = each %session) {
next; next unless (ref $hash eq 'HASH');
#$value = '['.join(', ',@$value).']'; while (my ($key, $value) = each %$hash) {
} elsif (ref $value eq 'HASH') { unless (lc($key) eq "password" || lc($key) eq "identifier") {
next; $t->param("session.".$section.".".$key=>$value);
#$value = '{'.join(', ',map {"$_ => $value->{$_}"} keys %$value).'}'; }
} }
unless (lc($key) eq "password" || lc($key) eq "identifier") { }
$t->param("session.".$section.".".$key=>$value); $t->param(%{$_[1]});
} $t->param("webgui.version"=>$WebGUI::VERSION);
} return $t->output;
} } else {
$t->param(%{$_[1]}); WebGUI::ErrorHandler::warn("Error in template. ".$@);
$t->param("webgui.version"=>$WebGUI::VERSION); return WebGUI::International::get(848).$html;
return $t->output; }
} }