summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Template.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/Template.pm')
-rw-r--r--Bugzilla/Template.pm14
1 files changed, 9 insertions, 5 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 81d01b426..f70224a9c 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -96,12 +96,15 @@ sub get_format {
my $self = shift;
my ($template, $format, $ctype) = @_;
- $ctype ||= 'html';
- $format ||= '';
+ $ctype //= 'html';
+ $format //= '';
- # Security - allow letters and a hyphen only
- $ctype =~ s/[^a-zA-Z\-]//g;
- $format =~ s/[^a-zA-Z\-]//g;
+ # ctype and format can have letters and a hyphen only.
+ if ($ctype =~ /[^a-zA-Z\-]/ || $format =~ /[^a-zA-Z\-]/) {
+ ThrowUserError('format_not_found', {'format' => $format,
+ 'ctype' => $ctype,
+ 'invalid' => 1});
+ }
trick_taint($ctype);
trick_taint($format);
@@ -127,6 +130,7 @@ sub get_format {
return
{
'template' => $template,
+ 'format' => $format,
'extension' => $ctype,
'ctype' => Bugzilla::Constants::contenttypes->{$ctype}
};