summaryrefslogtreecommitdiffstats
path: root/globals.pl
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2005-08-25 23:02:39 +0200
committerlpsolit%gmail.com <>2005-08-25 23:02:39 +0200
commit2a5664ad1abf679b9e50a6c409902ce2ef638cc5 (patch)
tree96de597ded0b88bd26e51f75e86a7d66c4305b7f /globals.pl
parentf1f97d1ce4e9d90680aca0adc97e7b5f97c6cc25 (diff)
downloadbugzilla-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.pl48
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;