diff options
author | lpsolit%gmail.com <> | 2005-08-25 23:02:39 +0200 |
---|---|---|
committer | lpsolit%gmail.com <> | 2005-08-25 23:02:39 +0200 |
commit | 2a5664ad1abf679b9e50a6c409902ce2ef638cc5 (patch) | |
tree | 96de597ded0b88bd26e51f75e86a7d66c4305b7f /globals.pl | |
parent | f1f97d1ce4e9d90680aca0adc97e7b5f97c6cc25 (diff) | |
download | bugzilla-2a5664ad1abf679b9e50a6c409902ce2ef638cc5.tar.gz bugzilla-2a5664ad1abf679b9e50a6c409902ce2ef638cc5.tar.xz |
Bug 208761: Move GetFormat() from globals.pl into Bugzilla::Template - Patch by Frédéric Buclin <LpSolit@gmail.com> r=wicked a=justdave
Diffstat (limited to 'globals.pl')
-rw-r--r-- | globals.pl | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/globals.pl b/globals.pl index 17174540a..6e9dcbeba 100644 --- a/globals.pl +++ b/globals.pl @@ -1082,54 +1082,6 @@ sub OpenStates { return ('NEW', 'REOPENED', 'ASSIGNED', 'UNCONFIRMED'); } - -############################################################################### - -# Constructs a format object from URL parameters. You most commonly call it -# like this: -# my $format = GetFormat("foo/bar", scalar($cgi->param('format')), -# scalar($cgi->param('ctype'))); - -sub GetFormat { - my ($template, $format, $ctype) = @_; - - $ctype ||= "html"; - $format ||= ""; - - # Security - allow letters and a hyphen only - $ctype =~ s/[^a-zA-Z\-]//g; - $format =~ s/[^a-zA-Z\-]//g; - trick_taint($ctype); - trick_taint($format); - - $template .= ($format ? "-$format" : ""); - $template .= ".$ctype.tmpl"; - - # Now check that the template actually exists. We only want to check - # if the template exists; any other errors (eg parse errors) will - # end up being detected later. - eval { - Bugzilla->template->context->template($template); - }; - # This parsing may seem fragile, but its OK: - # http://lists.template-toolkit.org/pipermail/templates/2003-March/004370.html - # Even if it is wrong, any sort of error is going to cause a failure - # eventually, so the only issue would be an incorrect error message - if ($@ && $@->info =~ /: not found$/) { - ThrowUserError("format_not_found", { 'format' => $format, - 'ctype' => $ctype, - }); - } - - # Else, just return the info - return - { - 'template' => $template , - 'extension' => $ctype , - 'ctype' => Bugzilla::Constants::contenttypes->{$ctype} , - }; -} - ############# Live code below here (that is, not subroutine defs) ############# use Bugzilla; |